core

package
v0.0.1-9 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 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 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