core

package
v0.0.5-18 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUBSCRIBE   = "subscribe"
	UNSUBSCRIBE = "unsubscribe"
	DEFAULT     = "default"
)

Variables

This section is empty.

Functions

func ContentTypesToContentIds

func ContentTypesToContentIds(contentTypes []string) []string

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) More

func (suggester *CollectionSuggester) More(request MoreRequest) ([]ContentItem, 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) More

func (suggester *CompletionSuggester) More(request MoreRequest) ([]ContentItem, 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) More

func (suggester *ContentUnitsSuggester) More(request MoreRequest) ([]ContentItem, error)

type Feed

type Feed struct {
	Suggesters []Suggester
}

func MakeFeed

func MakeFeed(db *sql.DB) *Feed

func (*Feed) More

func (f *Feed) More(r MoreRequest) ([]ContentItem, error)

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"`
}

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 Recommend

type Recommend struct {
	Uid string `json:"uid"`
}

type RoundRobinSuggester

type RoundRobinSuggester struct {
	// contains filtered or unexported fields
}

func MakeRoundRobinSuggester

func MakeRoundRobinSuggester(suggesters []Suggester) *RoundRobinSuggester

func (*RoundRobinSuggester) More

func (suggester *RoundRobinSuggester) More(request MoreRequest) ([]ContentItem, 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) More

func (suggester *SortSuggester) More(request MoreRequest) ([]ContentItem, error)

type Subscriptions

type Subscriptions map[string]string

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)
}

Jump to

Keyboard shortcuts

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