models

package
v0.0.0-...-831c856 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: BSD-2-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NumResultsPerPage = 50
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Approval

type Approval struct {
	VideoID string `db:"video_id"`
}

type BayesianTagSum

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

Dumb recommender system, computes expected rating value for user from a video's tags and orders by sum No more train otomads??? (please)

func NewBayesianTagSum

func NewBayesianTagSum(db *sqlx.DB, m *VideoModel) BayesianTagSum

func (*BayesianTagSum) GetNeighbors

func (b *BayesianTagSum) GetNeighbors(videoID int64, n int64) (*NeighborResults, error)

func (*BayesianTagSum) GetPopular

func (b *BayesianTagSum) GetPopular(n int64) (*NeighborResults, error)

TODO: remove read items for given user (even if anonymous)

func (*BayesianTagSum) GetRecommendations

func (b *BayesianTagSum) GetRecommendations(uid int64, vid int64) ([]*videoproto.Video, error)

func (*BayesianTagSum) GetRecommended

func (b *BayesianTagSum) GetRecommended(userID int64, n int64) ([]string, error)

func (*BayesianTagSum) RemoveRecommendedVideoForUser

func (b *BayesianTagSum) RemoveRecommendedVideoForUser(userID, videoID int64) error

type ESVideoResp

type ESVideoResp struct {
	Took     int  `json:"took"`
	TimedOut bool `json:"timed_out"`
	Shards   struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Skipped    int `json:"skipped"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
	Hits struct {
		Total struct {
			Value    int    `json:"value"`
			Relation string `json:"relation"`
		} `json:"total"`
		MaxScore any `json:"max_score"`
		Hits     []struct {
			Index  string `json:"_index"`
			Type   string `json:"_type"`
			ID     string `json:"_id"`
			Score  any    `json:"_score"`
			Source struct {
				Videoid       int      `json:"videoid"`
				Title         string   `json:"title"`
				Tags          []string `json:"tags"`
				CommentCount  int      `json:"comment_count"`
				Category      string   `json:"category"`
				FavoriteArr   []any    `json:"favorite_arr"`
				UploadDate    string   `json:"upload_date"`
				Userid        int      `json:"userid"`
				Newlink       string   `json:"newlink"`
				VideoDuration float64  `json:"video_duration"`
				Views         int      `json:"views"`
				Rating        int      `json:"rating"`
				IsDeleted     bool     `json:"is_deleted"`
				Transcoded    bool     `json:"transcoded"`
				TooBig        bool     `json:"too_big"`
				IsApproved    bool     `json:"is_approved"`
				ZdbCtid       int64    `json:"zdb_ctid"`
				ZdbCmin       int      `json:"zdb_cmin"`
				ZdbCmax       int      `json:"zdb_cmax"`
				ZdbXmin       int      `json:"zdb_xmin"`
			} `json:"_source"`
		} `json:"hits"`
	} `json:"hits"`
	Aggregations struct {
		Cardinalities struct {
			DocCountErrorUpperBound int `json:"doc_count_error_upper_bound"`
			SumOtherDocCount        int `json:"sum_other_doc_count"`
			Buckets                 []struct {
				Key      string `json:"key"`
				DocCount int    `json:"doc_count"`
			} `json:"buckets"`
		} `json:"cardinalities"`
	} `json:"aggregations"`
}

type NeighborResults

type NeighborResults []struct {
	ID    string  `json:"Id"`
	Score float64 `json:"Score"`
}

type Recommender

type Recommender interface {
	GetRecommendations(userID int64, vid int64) ([]*videoproto.Video, error)
	RemoveRecommendedVideoForUser(userID, videoID int64) error
}

TODO: test suite for recommender implementations with precision and recall for sample dataset

type Tag

type Tag struct {
	Tag string `db:"tag"`
}

type UnencodedVideo

type UnencodedVideo struct {
	ID      uint32 `db:"id"`
	NewLink string `db:"newlink"`
}

func (UnencodedVideo) GetMPDUUID

func (v UnencodedVideo) GetMPDUUID() string

type VideoModel

type VideoModel struct {
	ApprovalThreshold int
	// contains filtered or unexported fields
}

func NewVideoModel

func NewVideoModel(db *sqlx.DB, client proto.UserServiceClient, approvalThreshold int) (*VideoModel, error)

func (*VideoModel) AddRatingToVideoID

func (v *VideoModel) AddRatingToVideoID(ratingUID, videoID int64, ratingValue float64) error

func (*VideoModel) ApproveVideo

func (v *VideoModel) ApproveVideo(userID, videoID int) error

Individual trusted user approves of the video

func (*VideoModel) DeleteComment

func (v *VideoModel) DeleteComment(commentID, userID int64) error

func (*VideoModel) DeleteVideo

func (v *VideoModel) DeleteVideo(videoID string) error

func (*VideoModel) ForeignVideoExists

func (v *VideoModel) ForeignVideoExists(foreignVideoID, website string) (bool, error)

func (*VideoModel) GetAverageRatingForVideoID

func (v *VideoModel) GetAverageRatingForVideoID(videoID int64) (int, error)

func (*VideoModel) GetCategories

func (v *VideoModel) GetCategories() (*videoproto.CategoryList, error)

func (*VideoModel) GetComments

func (v *VideoModel) GetComments(videoID, currUserID int64) ([]*videoproto.Comment, error)

func (*VideoModel) GetDanmaku

func (v *VideoModel) GetDanmaku(videoID int) (*videoproto.DanmakuList, error)

func (*VideoModel) GetUnencodedVideos

func (v *VideoModel) GetUnencodedVideos() ([]UnencodedVideo, error)

func (*VideoModel) GetVideoInfo

func (v *VideoModel) GetVideoInfo(videoID string) (*videoproto.VideoMetadata, error)

Information that isn't super straightforward to query for

func (*VideoModel) GetVideoList

func (v *VideoModel) GetVideoList(direction videoproto.SortDirection, pageNum int64, fromUserID int64, searchVal string, showUnapproved, unapprovedOnly bool,
	orderCategory videoproto.OrderCategory, category string, followFeed bool, following []int64) ([]*videoproto.Video, int, *videoproto.CategoryList, error)

For now, this only supports either fromUserID or withTag. Can support both in future, need to switch to goqu and write better tests

func (*VideoModel) GetVideoRecommendations

func (v *VideoModel) GetVideoRecommendations(userID int64, videoID int64) (*videoproto.RecResp, error)

func (*VideoModel) IncrementViewsForVideo

func (v *VideoModel) IncrementViewsForVideo(videoID int64) error

func (*VideoModel) MakeComment

func (v *VideoModel) MakeComment(userID, videoID, parentID int64, content string) error

Comment stuff

func (*VideoModel) MakeDanmaku

func (v *VideoModel) MakeDanmaku(video_id int, timestamp, message string, authorID int, inpType, color, fontSize string) error

func (*VideoModel) MakeUpvote

func (v *VideoModel) MakeUpvote(userID, commentID int64, voteScore int) error

func (*VideoModel) MarkApprovals

func (v *VideoModel) MarkApprovals() error

func (*VideoModel) MarkVideoApproved

func (v *VideoModel) MarkVideoApproved(videoID string) error

func (*VideoModel) MarkVideoAsEncoded

func (v *VideoModel) MarkVideoAsEncoded(uv UnencodedVideo) error

func (*VideoModel) MarkVideoAsTooBig

func (v *VideoModel) MarkVideoAsTooBig(uv UnencodedVideo) error

func (*VideoModel) RefreshMaterializedView

func (v *VideoModel) RefreshMaterializedView() error

func (*VideoModel) SaveForeignVideo

func (v *VideoModel) SaveForeignVideo(ctx context.Context, title, description string, foreignAuthorUsername string, foreignAuthorID string,
	originalSite string, originalVideoLink, originalVideoID, newURI string, tags []string, domesticAuthorID int64, videoDuration float64, category string) (int64, error)

check if user has been created if it hasn't, then create it list user as parent of this video FIXME this signature is too long lol If domesticAuthorID is 0, will interpret as foreign video from foreign user

Jump to

Keyboard shortcuts

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