models

package
v0.0.0-...-514e0f0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 15 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) BayesianTagSum

func (*BayesianTagSum) GetRecommendations

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

func (*BayesianTagSum) RemoveRecommendedVideoForUser

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

type Recommender

type Recommender interface {
	GetRecommendations(userID int64) ([]*videoproto.VideoRec, 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) 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) (float64, error)

func (*VideoModel) GetComments

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

func (*VideoModel) GetNumberOfSearchResultsForQuery

func (v *VideoModel) GetNumberOfSearchResultsForQuery(fromUserID int64, searchVal string, showUnapproved, unapprovedOnly bool) (int64, error)

FIXME: optimization: move to redis once I figure out what types of queries are necessary

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,
	category videoproto.OrderCategory) ([]*videoproto.Video, 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) (*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) MakeUpvote

func (v *VideoModel) MakeUpvote(userID, commentID int64, isUpvote bool) 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) 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) (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