Documentation ¶
Index ¶
- Constants
- Variables
- func CollectionsByFirstUnitLanguagesTableSql(contentTypes []string, languages []string) string
- func ContentTypesToContentIds(contentTypes []string) []string
- func ContentTypesToInt64Ids(contentTypes []string) []int64
- func FilterByLanguageSql(languages []string) string
- func RegisterSuggester(name string, makeFunc MakeSuggesterFunc)
- func SplitContentItems(contentItems []ContentItem, numLists int) [][]ContentItem
- type CollectionSuggester
- type CompletionSuggester
- type ContentItem
- type ContentUnitsSuggester
- type Feed
- type FilterSelectorEnum
- type MakeSuggesterFunc
- type MoreOptions
- type MoreRequest
- type OrderSelectorEnum
- type Recommend
- type RoundRobinSuggester
- type SortSuggester
- type Subscriptions
- type Suggester
- type SuggesterContext
- type SuggesterFilter
- type SuggesterSpec
Constants ¶
View Source
const ( SUBSCRIBE = "subscribe" UNSUBSCRIBE = "unsubscribe" DEFAULT = "default" )
View Source
const COLLECTIONS_BY_FIRST_CONTENT_UNIT_CLAUSE = `
and c.id = collection_first_content_unit_languages.collection_id
`
Filter collection to have language.
View Source
const CONTENT_UNIT_PERSON_RAV = `` /* 178-byte string literal not displayed */
View Source
const CONTENT_UNIT_SUGGESTER_NAME = "ContentUnitsSuggester"
Variables ¶
View Source
var FILTER_STRING_TO_VALUE = map[string]FilterSelectorEnum{ "FUnitContentTypes": UnitContentTypes, "FCollectionContentTypes": CollectionContentTypes, "FTags": Tags, "FSources": Sources, "FCollections": Collections, "FSameTag": SameTag, "FSameSource": SameSource, "FSameCollection": SameCollection, }
View Source
var ORDER_STRING_TO_VALUE = map[string]OrderSelectorEnum{ "OLast": Last, "ONext": Next, "OPrev": Prev, "ORand": Rand, "OPopular": Popular, }
View Source
var Suggesters = map[string]MakeSuggesterFunc{}
Functions ¶
func ContentTypesToInt64Ids ¶
func FilterByLanguageSql ¶
Filter content unit to have language.
func RegisterSuggester ¶
func RegisterSuggester(name string, makeFunc MakeSuggesterFunc)
func SplitContentItems ¶
func SplitContentItems(contentItems []ContentItem, numLists int) [][]ContentItem
Types ¶
type CollectionSuggester ¶
type CollectionSuggester struct {
// contains filtered or unexported fields
}
func MakeCollectionSuggester ¶
func MakeCollectionSuggester(db *sql.DB, contentType string) *CollectionSuggester
func (*CollectionSuggester) MarshalSpec ¶
func (suggester *CollectionSuggester) MarshalSpec() (SuggesterSpec, error)
func (*CollectionSuggester) More ¶
func (suggester *CollectionSuggester) More(request MoreRequest) ([]ContentItem, error)
func (*CollectionSuggester) UnmarshalSpec ¶
func (suggester *CollectionSuggester) UnmarshalSpec(suggesterContext SuggesterContext, spec SuggesterSpec) error
type CompletionSuggester ¶
type CompletionSuggester struct {
// contains filtered or unexported fields
}
Given slice of Suggesters will take the first one, if not enough suggestions will take the second one, ect... The OriginalOrder here is the index of the suggester, e.g., 0, 0, 0, 1, 1, 2, 2, 2, 2 (3 items from suggeter #0, 2 from #1, 4 from #4)
func MakeCompletionSuggester ¶
func MakeCompletionSuggester(suggesters []Suggester) *CompletionSuggester
func (*CompletionSuggester) MarshalSpec ¶
func (suggester *CompletionSuggester) MarshalSpec() (SuggesterSpec, error)
func (*CompletionSuggester) More ¶
func (suggester *CompletionSuggester) More(request MoreRequest) ([]ContentItem, error)
func (*CompletionSuggester) UnmarshalSpec ¶
func (suggester *CompletionSuggester) UnmarshalSpec(suggesterContext SuggesterContext, spec SuggesterSpec) error
type ContentItem ¶
type ContentItem struct { UID string `json:"uid"` ContentType string `json:"content_type"` Date time.Time `json:"date"` CreatedAt time.Time `json:"created_at"` OriginalOrder []int64 `json:"original_order"` Suggester string `json:"suggester"` }
func Merge ¶
func Merge(r MoreRequest, suggestions [][]ContentItem) ([]ContentItem, error)
func Unsort ¶
func Unsort(contentItems []ContentItem) []ContentItem
type ContentUnitsSuggester ¶
type ContentUnitsSuggester struct {
// contains filtered or unexported fields
}
func MakeContentUnitsSuggester ¶
func MakeContentUnitsSuggester(db *sql.DB, contentTypes []string) *ContentUnitsSuggester
func (*ContentUnitsSuggester) MarshalSpec ¶
func (suggester *ContentUnitsSuggester) MarshalSpec() (SuggesterSpec, error)
func (*ContentUnitsSuggester) More ¶
func (suggester *ContentUnitsSuggester) More(request MoreRequest) ([]ContentItem, error)
func (*ContentUnitsSuggester) UnmarshalSpec ¶
func (suggester *ContentUnitsSuggester) UnmarshalSpec(suggesterContext SuggesterContext, spec SuggesterSpec) error
type Feed ¶
type Feed struct {
Suggester Suggester
}
func MakeFeed ¶
func MakeFeed(suggesterContext SuggesterContext) *Feed
func (*Feed) More ¶
func (f *Feed) More(r MoreRequest) ([]ContentItem, error)
type FilterSelectorEnum ¶
type FilterSelectorEnum int
Define filter constrain for unit being watched.
const ( UnitContentTypes FilterSelectorEnum = iota CollectionContentTypes Tags Sources Collections SameTag SameSource SameCollection )
type MakeSuggesterFunc ¶
type MakeSuggesterFunc func(suggesterContext SuggesterContext) Suggester
type MoreOptions ¶
type MoreOptions struct { ContentTypes Subscriptions `json:"content_types" form:"content_type"` // Map from collection content type to Subscriptions. Collections map[string]Subscriptions `json:"collections" form:"collections"` Recommend Recommend `json:"recommend" form:"recommend"` Spec *SuggesterSpec `json:"spec,omitempty" form:"spec,omitempty"` Specs []*SuggesterSpec `json:"specs,omitempty" form:"specs,omitempty"` Languages []string `json:"languages,omitempty" form:"languages,omitempty"` SkipUids []string `json:"skip_uids"` }
type MoreRequest ¶
type MoreRequest struct { CurrentFeed []ContentItem `json:"current_feed" form:"current_feed"` MoreItems int `json:"more_items" form:"more_items"` Options MoreOptions `json:"options" form:"options"` }
type OrderSelectorEnum ¶
type OrderSelectorEnum int
Defines order constrain for selecting content units / collection.
const ( Last OrderSelectorEnum = iota Next Prev Rand Popular )
type RoundRobinSuggester ¶
func MakeRoundRobinSuggester ¶
func MakeRoundRobinSuggester(suggesters []Suggester) *RoundRobinSuggester
func (*RoundRobinSuggester) MarshalSpec ¶
func (suggester *RoundRobinSuggester) MarshalSpec() (SuggesterSpec, error)
func (*RoundRobinSuggester) More ¶
func (suggester *RoundRobinSuggester) More(request MoreRequest) ([]ContentItem, error)
func (*RoundRobinSuggester) UnmarshalSpec ¶
func (suggester *RoundRobinSuggester) UnmarshalSpec(suggesterContext SuggesterContext, spec SuggesterSpec) error
type SortSuggester ¶
type SortSuggester struct {
// contains filtered or unexported fields
}
Sort items by date and then by create at time.
func MakeSortSuggester ¶
func MakeSortSuggester(suggester Suggester) *SortSuggester
func (*SortSuggester) MarshalSpec ¶
func (suggester *SortSuggester) MarshalSpec() (SuggesterSpec, error)
func (*SortSuggester) More ¶
func (suggester *SortSuggester) More(request MoreRequest) ([]ContentItem, error)
func (*SortSuggester) UnmarshalSpec ¶
func (suggester *SortSuggester) UnmarshalSpec(suggesterContext SuggesterContext, spec SuggesterSpec) error
type Subscriptions ¶
Keys are content types or collection mids. Values are one of the constants: SUBSCRIBE, UNSUBSCRIBE, DEFAULT
type Suggester ¶
type Suggester interface { More(request MoreRequest) ([]ContentItem, error) MarshalSpec() (SuggesterSpec, error) UnmarshalSpec(suggesterContext SuggesterContext, spec SuggesterSpec) error }
func MakeSuggesterFromName ¶
func MakeSuggesterFromName(suggesterContext SuggesterContext, name string) (Suggester, error)
type SuggesterContext ¶
type SuggesterContext struct { DB *sql.DB DataModels *data_models.DataModels Cache map[string]interface{} }
type SuggesterFilter ¶
type SuggesterFilter struct { FilterSelector FilterSelectorEnum `json:"filter_selector,omitempty" form:"filter_selector,omitempty"` Args []string `json:"args,omitempty" form:"args,omitempty"` }
type SuggesterSpec ¶
type SuggesterSpec struct { Name string `json:"name,omitempty" form:"name,omitempty"` Filters []SuggesterFilter `json:"filters,omitempty" form:"filters,omitempty"` OrderSelector OrderSelectorEnum `json:"order_selector,omitempty" form:"order_selector,omitempty"` Specs []SuggesterSpec `json:"specs,omitempty" form:"specs,omitempty"` // Deprecated Args []string `json:"args,omitempty" form:"args,omitempty"` SecondArgs []string `json:"second_args,omitempty" form:"second_args,omitempty"` }
Click to show internal directories.
Click to hide internal directories.