structs

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2017 License: MIT Imports: 15 Imported by: 56

Documentation

Index

Constants

View Source
const (
	ShowAll       Status = 0
	FilterRemakes        = 2
	Trusted              = 3
	APlus                = 4
)

Variables

This section is empty.

Functions

func ParseLanguages

func ParseLanguages(s string) publicSettings.Languages

ParseLanguages sets languages by string

Types

type Categories

type Categories []*Category

type Category

type Category struct {
	Main, Sub uint8
}

func ParseCategories

func ParseCategories(s string) []*Category

ParseCategories sets category by string

func (Category) IsMainSet

func (c Category) IsMainSet() bool

func (Category) IsSet

func (c Category) IsSet() bool

func (Category) IsSubSet

func (c Category) IsSubSet() bool

func (Category) String

func (c Category) String() (s string)

type DateFilter

type DateFilter string

func (*DateFilter) Parse

func (d *DateFilter) Parse(s string, dateType string) bool

type SizeBytes

type SizeBytes uint64

func (*SizeBytes) Parse

func (sz *SizeBytes) Parse(s string, sizeType string) bool

type SortMode

type SortMode uint8
const (
	ID SortMode = iota
	Name
	Date
	Downloads
	Size
	Seeders
	Leechers
	Completed
)

func (*SortMode) Parse

func (s *SortMode) Parse(str string)

func (*SortMode) ToDBField

func (s *SortMode) ToDBField() string

func (*SortMode) ToESField

func (s *SortMode) ToESField() string

INFO Always need to keep in sync with the field that are used in the * elasticsearch index. * TODO Verify the field in postgres database

type Status

type Status uint8

func (*Status) Parse

func (st *Status) Parse(s string)

func (*Status) ToString

func (st *Status) ToString() string

type TorrentCache

type TorrentCache struct {
	Torrents []models.Torrent
	Count    int
}

type TorrentParam

type TorrentParam struct {
	Full      bool // True means load all members
	Order     bool // True means ascending
	Hidden    bool // True means filter hidden torrents
	Deleted   bool // False means filter deleted torrents
	Status    Status
	Sort      SortMode
	Category  Categories
	Max       uint32
	Offset    uint32
	UserID    uint32
	TorrentID uint32
	FromID    uint32
	FromDate  DateFilter
	ToDate    DateFilter
	NotNull   string // csv
	NameLike  string // csv
	Languages publicSettings.Languages
	MinSize   SizeBytes
	MaxSize   SizeBytes
}

TorrentParam defines all parameters that can be provided when searching for a torrent

func (*TorrentParam) Clone

func (p *TorrentParam) Clone() TorrentParam

Clone : To clone a torrent params

func (*TorrentParam) Find

func (p *TorrentParam) Find(client *elastic.Client) (int64, []models.Torrent, error)

Find :

Uses elasticsearch to find the torrents based on TorrentParam
* We decided to fetch only the ids from ES and then query these ids to the
* database

func (*TorrentParam) FromRequest

func (p *TorrentParam) FromRequest(c *gin.Context)

FromRequest : parse a request in torrent param TODO Should probably return an error ?

func (*TorrentParam) Identifier

func (p *TorrentParam) Identifier() string

func (*TorrentParam) ToFilterQuery

func (p *TorrentParam) ToFilterQuery() string

ToFilterQuery : Builds a query string with for es query string query defined here https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html

type WhereParams

type WhereParams struct {
	Conditions string // Ex : name LIKE ? AND category_id LIKE ?
	Params     []interface{}
}

WhereParams struct for search

func CreateWhereParams

func CreateWhereParams(conditions string, params ...interface{}) WhereParams

CreateWhereParams : function to create WhereParams struct for search

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL