Documentation
¶
Index ¶
- Variables
- func UpdateRating[U UpdateableKeyTypes](ctx context.Context, rs *RatingStorage, id int64, values []U) (err error)
- type Album
- type Book
- type BookValues
- type Cast
- type CastRating
- type City
- type Country
- type Entity
- type Episode
- type Film
- type Genre
- type Group
- type Image
- type Keyword
- type KeywordStorage
- func (ks *KeywordStorage) AddKeyword(ctx context.Context, keyword string, mediaID uuid.UUID) (err error)
- func (ks *KeywordStorage) CastVote(ctx context.Context, k Keyword) error
- func (ks *KeywordStorage) GetAll(ctx context.Context) (keywords []Keyword, err error)
- func (ks *KeywordStorage) GetKeyword(ctx context.Context, keyword string, mediaID uuid.UUID) (k Keyword, err error)
- func (ks *KeywordStorage) GetKeywords(ctx context.Context, mediaID uuid.UUID) (keywords []Keyword, err error)
- func (ks *KeywordStorage) RemoveVote(ctx context.Context, k Keyword) error
- type KeywordStorer
- type LangID
- type Media
- type MediaService
- type MediaStorage
- func (ms *MediaStorage) Add(ctx context.Context, db *sqlx.DB, media MediaService, props Media) error
- func (ms *MediaStorage) Delete(ctx context.Context, key interface{}, objType interface{}) error
- func (ms *MediaStorage) Get(ctx context.Context, id uuid.UUID) (media any, err error)
- func (ms *MediaStorage) GetAll() ([]*interface{}, error)
- func (ms *MediaStorage) Update(ctx context.Context, key, value interface{}, objType interface{}) error
- type MediaStorer
- type Member
- type MemberInput
- type MemberStorage
- func (s *MemberStorage) Delete(ctx context.Context, member *Member) error
- func (s *MemberStorage) GetPassHash(email, login string) (string, error)
- func (s *MemberStorage) Read(ctx context.Context, keyName, key string) (*Member, error)
- func (s *MemberStorage) Save(ctx context.Context, member *Member) error
- func (s *MemberStorage) Update(ctx context.Context, member *Member) error
- type MemberStorer
- type MusicValues
- type Person
- type Place
- type Rating
- type RatingInput
- type RatingStorage
- func (rs *RatingStorage) Get(ctx context.Context, id int64) (r Rating, err error)
- func (rs *RatingStorage) GetAll() (ratings []*Rating, err error)
- func (rs *RatingStorage) GetAverageStars(ctx context.Context, rating interface{}, mediaID uuid.UUID) (avgStars float64, err error)
- func (rs *RatingStorage) GetByMediaID(ctx context.Context, mediaID uuid.UUID) (ratings []*Rating, err error)
- func (rs *RatingStorage) GetLatest(ctx context.Context, limit int, offset int) (ratings []*Rating, err error)
- func (rs *RatingStorage) New(ctx context.Context, rating *RatingInput) error
- type RatingStorer
- type Season
- type Studio
- type TVShow
- type Track
- type TrackRating
- type UpdateableKeyTypes
- type Venue
Constants ¶
This section is empty.
Variables ¶
View Source
var ( BookKeys = []string{ "media_id", "title", "authors", "genres", "edition", "languages", } AlbumKeys = [7]string{ "media_id", "title", "artists", "genres", "keywords", "languages", "cover", } TrackKeys = [7]string{ "media_id", "title", "artists", "genres", "keywords", "languages", "cover", } GenreKeys = [5]string{ "id", "name", "desc_short", "desc_long", "keywords", } )
strictly necessary (not nil keys for each media type)
View Source
var GroupKinds = []string{
"Orchestra",
"Choir",
"Ensemble",
"Collective",
"Band",
"Troupe",
"Other",
}
Functions ¶
func UpdateRating ¶
func UpdateRating[U UpdateableKeyTypes](ctx context.Context, rs *RatingStorage, id int64, values []U) (err error)
Types ¶
type Album ¶
type Album struct {
MediaID *uuid.UUID `json:"media_id" db:"media_id,pk,unique"`
Name string `json:"name" db:"name"`
AlbumArtists mo.Either[[]Person, []Group] `json:"album_artists" db:"album_artists"`
ReleaseDate time.Time `json:"release_date" db:"release_date"`
Genres []Genre `json:"genres,omitempty" db:"genres"`
Studio Studio `json:"studio,omitempty" db:"studio"`
Keywords []string `json:"keywords,omitempty" db:"keywords"`
Duration time.Duration `json:"duration" db:"duration"`
Tracks []Track `json:"tracks" db:"tracks"`
Languages []string `json:"languages" db:"languages,omitempty"`
}
type Book ¶
type Book struct {
MediaID *uuid.UUID `json:"media_id" db:"media_id,pk,unique"`
Title string `json:"title" db:"title"`
Authors []Person `json:"author" db:"author"`
Publisher string `json:"publisher" db:"publisher"`
PublicationDate time.Time `json:"publication_date" db:"publication_date"`
Genres []string `json:"genres" db:"genres"`
Keywords []string `json:"keywords,omitempty" db:"keywords,omitempty"`
Languages []string `json:"languages" db:"languages"`
Pages int16 `json:"pages" db:"pages"`
ISBN string `json:"isbn,omitempty" db:"isbn,unique,omitempty"`
ASIN string `json:"asin,omitempty" db:"asin,unique,omitempty"`
Cover string `json:"cover,omitempty" db:"cover,omitempty"`
Summary string `json:"summary" db:"summary"`
}
type Cast ¶
type Cast struct {
Actors []Person `json:"actors" db:"actors"`
Directors []Person `json:"directors" db:"directors"`
}
TODO: add more fields
type CastRating ¶
type Episode ¶
type Episode struct {
MediaID *uuid.UUID `json:"media_id" db:"media_id,pk,unique"`
ShowID *uuid.UUID `json:"show_id" db:"show_id,pk,unique"`
SeasonID *uuid.UUID `json:"season_id" db:"season_id,pk,unique"`
Number uint16 `json:"number" db:"number,autoinc"`
Title string `json:"title" db:"title"`
Season uint16 `json:"season" db:"season"`
Episode uint16 `json:"episode" db:"episode"`
AirDate time.Time `json:"air_date" db:"air_date"`
Duration time.Duration `json:"duration" db:"duration"`
Languages []string `json:"languages" db:"languages"`
Plot string `json:"plot" db:"plot"`
}
type Film ¶
type Genre ¶
type Genre struct {
ID int16 `json:"id" db:"id,pk,autoinc"`
Name string `json:"name" db:"name"`
DescShort string `json:"desc_short" db:"desc_short"`
DescLong string `json:"desc_long" db:"desc_long"`
Keywords []string `json:"keywords" db:"keywords"`
ParentGenre *Genre `json:"parent_genre omitempty" db:"parent"`
Children []Genre `json:"children omitempty" db:"children"`
}
Genre does not hage a UUID due to parent-child relationships
type Group ¶
type Group struct {
ID int32 `json:"id" db:"id"`
Locations []Place `json:"locations,omitempty" db:"locations"`
Name string `json:"name" db:"name"`
Active bool `json:"active" db:"active"`
Formed sql.NullTime `json:"formed,omitempty" db:"formed"`
Disbanded sql.NullTime `json:"disbanded,omitempty" db:"disbanded"`
Website string `json:"website,omitempty" db:"website"`
Photos []string `json:"photos,omitempty" db:"photos"`
Works []*uuid.UUID `json:"works,omitempty" db:"works"`
Members []Person `json:"members,omitempty" db:"members"`
PrimaryGenre Genre `json:"primary_genre,omitempty" db:"primary_genre_id"`
SecondaryGenres []Genre `json:"genres,omitempty" db:"genres"`
Kind string `json:"kind,omitempty" db:"kind"` // Orchestra, Choir, Ensemble, Collective, etc.
Added time.Time `json:"added" db:"added"`
Modified sql.NullTime `json:"modified,omitempty" db:"modified"`
Wikipedia string `json:"wikipedia,omitempty" db:"wikipedia"`
Bandcamp string `json:"bandcamp,omitempty" db:"bandcamp"`
Soundcloud string `json:"soundcloud,omitempty" db:"soundcloud"`
Bio string `json:"bio,omitempty" db:"bio"`
}
type KeywordStorage ¶
type KeywordStorage struct {
// contains filtered or unexported fields
}
func NewKeywordStorage ¶
func NewKeywordStorage(db *sqlx.DB, log *zerolog.Logger) *KeywordStorage
func (*KeywordStorage) AddKeyword ¶
func (*KeywordStorage) CastVote ¶
func (ks *KeywordStorage) CastVote(ctx context.Context, k Keyword) error
func (*KeywordStorage) GetAll ¶
func (ks *KeywordStorage) GetAll(ctx context.Context) (keywords []Keyword, err error)
func (*KeywordStorage) GetKeyword ¶
func (*KeywordStorage) GetKeywords ¶
func (*KeywordStorage) RemoveVote ¶
func (ks *KeywordStorage) RemoveVote(ctx context.Context, k Keyword) error
type KeywordStorer ¶
type KeywordStorer interface {
CastVote(ctx context.Context, k Keyword) error
RemoveVote(ctx context.Context, k Keyword) error
AddKeyword(ctx context.Context, k Keyword) error
GetKeyword(ctx context.Context, mediaID uuid.UUID) (Keyword, error)
GetKeywords(ctx context.Context, mediaID uuid.UUID) ([]Keyword, error)
}
type LangID ¶
type LangID int16
const ( English LangID = iota Spanish French German Chinese Japanese Korean Arabic Hebrew Hindi Polish Russian Czech Dutch Greek Italian Swedish Turkish Norwegian Portuguese Finnish Thai Indonesian Vietnamese Farsi Tagalog Swahili Serbian Croatian Bosnian Slovenian Slovak Macedonian Albanian Bulgarian Romanian Hungarian Latvian Lithuanian Estonian Ukrainian Belarusian Malay Malayalam Tamil Telugu Kannada Marathi Gujarati Bengali Punjabi Urdu Mongolian Amharic Icelandic Maltese Unknown Others )
type Media ¶
type Media struct {
UUID uuid.UUID `json:"uuid" db:"uuid,pk,unique"`
Kind string `json:"kind" db:"kind"`
Name string `json:"name" db:"name"`
Genres []Genre `json:"genres,omitempty" db:"genres"`
Keywords []string `json:"keywords,omitempty" db:"keywords"` // WARN: should this really be nullable?
LangIDs []int16 `json:"lang_ids,omitempty" db:"lang_ids"`
Creators []Person `json:"creators,omitempty" db:"creators"`
}
type MediaService ¶
type MediaService interface {
IsMedia() bool // dummy placeholder so that we can have somewhat idiomatic parametric polymorphism
}
type MediaStorage ¶
type MediaStorage struct {
// contains filtered or unexported fields
}
func NewMediaStorage ¶
type MediaStorer ¶
type Member ¶
type Member struct {
ID uint32 `json:"id" db:"id"`
UUID string `json:"_key,omitempty" db:"uuid"`
PassHash string `json:"passhash" db:"passhash"`
MemberName string `json:"membername" db:"nick"` // i.e. @nick@instance
DisplayName sql.NullString `json:"displayname:omitempty" db:"display_name"`
Email string `json:"email" db:"email"`
Bio sql.NullString `json:"bio:omitempty" db:"bio"`
Active bool `json:"active" db:"active"`
Roles []uint8 `json:"roles" db:"roles"`
RegTimestamp time.Time `json:"regdate" db:"reg_timestamp"`
ProfilePic *Image `json:"profilepic:omitempty" db:"profilepic_id"`
Homepage sql.NullString `json:"homepage:omitempty" db:"homepage"`
IRC sql.NullString `json:"irc:omitempty" db:"irc"`
XMPP sql.NullString `json:"xmpp:omitempty" db:"xmpp"`
Matrix sql.NullString `json:"matrix:omitempty" db:"matrix"`
}
Member holds the core information about a member
type MemberInput ¶
type MemberStorage ¶
type MemberStorage struct {
// contains filtered or unexported fields
}
func NewMemberStorage ¶
func NewMemberStorage(client *sqlx.DB, log *zerolog.Logger) *MemberStorage
func (*MemberStorage) Delete ¶
func (s *MemberStorage) Delete(ctx context.Context, member *Member) error
func (*MemberStorage) GetPassHash ¶
func (s *MemberStorage) GetPassHash(email, login string) (string, error)
type MemberStorer ¶
type MusicValues ¶
type Person ¶
type Person struct {
ID int32 `json:"id" db:"id,pk,unique,autoincrement"`
FirstName string `json:"first_name" db:"first_name"`
OtherNames []string `json:"other_names,omitempty" db:"other_names"`
LastName string `json:"last_name" db:"last_name"`
NickNames []string `json:"nick_name,omitempty" db:"nick_name"`
Roles []string `json:"roles,omitempty" db:"roles"`
Works []*uuid.UUID `json:"works" db:"works"`
Birth sql.NullTime `json:"birth,omitempty" db:"birth"` // DOB can also be unknown
Death sql.NullTime `json:"death,omitempty" db:"death"`
Website string `json:"website,omitempty" db:"website"`
Bio string `json:"bio,omitempty" db:"bio"`
Photos []string `json:"photos,omitempty" db:"photos"`
Hometown Place `json:"hometown,omitempty" db:"hometown"`
Residence Place `json:"residence,omitempty" db:"residence"`
Added time.Time `json:"added" db:"added"`
Modified sql.NullTime `json:"modified,omitempty" db:"modified"`
}
type Rating ¶
type Rating struct {
ID int64 `json:"_key" db:"id,pk"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
NumStars uint8 `json:"numstars" binding:"required" validate:"min=1,max=10" error:"numstars must be between 1 and 10" db:"stars" `
Comment string `json:"comment,omitempty" db:"comment"`
Topic string `json:"topic,omitempty" db:"topic"`
Attribution string `json:"attribution,omitempty" db:"attribution"`
UserID uint32 `json:"userid" db:"user_id"`
MediaID uuid.UUID `json:"mediaid" db:"media_id"`
// track/cast/theme
TrackRatings *TrackRating `json:"trackRatings,omitempty" db:"track_rating"`
CastRating *CastRating `json:"castRating,omitempty" db:"cast_rating"`
}
type RatingInput ¶
type RatingInput struct {
// TODO: allow for setting dynamic rating scales
NumStars uint8 `json:"numstars" binding:"required" validate:"min=1,max=10" error:"numstars must be between 1 and 10" db:"stars"`
Comment string `json:"comment,omitempty" db:"comment"`
Topic string `json:"topic,omitempty" db:"topic"`
Attribution string `json:"attribution,omitempty" db:"attribution"`
UserID uint32 `json:"userid" db:"user_id"`
MediaID uuid.UUID `json:"mediaid" db:"media_id"`
}
type RatingStorage ¶
type RatingStorage struct {
// contains filtered or unexported fields
}
func NewRatingStorage ¶
func NewRatingStorage(db *sqlx.DB, log *zerolog.Logger) *RatingStorage
func (*RatingStorage) GetAll ¶
func (rs *RatingStorage) GetAll() (ratings []*Rating, err error)
func (*RatingStorage) GetAverageStars ¶
func (*RatingStorage) GetByMediaID ¶
func (*RatingStorage) GetLatest ¶
func (rs *RatingStorage) GetLatest(ctx context.Context, limit int, offset int) (ratings []*Rating, err error)
GetLatestRatings retrieves the latest reviews for all media items. The limit and offset parameters are used for pagination.
func (*RatingStorage) New ¶
func (rs *RatingStorage) New(ctx context.Context, rating *RatingInput) error
type RatingStorer ¶
type RatingStorer interface {
New(ri *RatingInput) error
Get(ctx context.Context, ID int64) (*Rating, error)
GetAll() ([]*Rating, error)
GetByMediaID(ctx context.Context, mediaID uuid.UUID) ([]*Rating, error)
}
Update is not present, because methods cannot have type parameters
type Season ¶
type Studio ¶
type Studio struct {
ID int32 `json:"id" db:"id,pk,serial,unique"`
Name string `json:"name" db:"name"`
Active bool `json:"active" db:"active"`
City *City `json:"city,omitempty" db:"city"`
Artists []Person `json:"artists,omitempty" db:"artists"`
Works Media `json:"works,omitempty" db:"works"`
IsFilm bool `json:"is_film" db:"is_film"`
IsMusic bool `json:"is_music" db:"is_music"`
IsTV bool `json:"is_tv" db:"is_tv"`
IsPublishing bool `json:"is_publishing" db:"is_publishing"`
IsGame bool `json:"is_game" db:"is_game"`
}
type TVShow ¶
type TVShow struct {
MediaID *uuid.UUID `json:"media_id" db:"media_id,pk,unique"`
Title string `json:"title" db:"title"`
Cast Cast `json:"cast" db:"cast"`
Year int `json:"year" db:"year"`
Active bool `json:"active" db:"active"`
Seasons []Season `json:"seasons" db:"seasons"`
Studio Studio `json:"studio" db:"studio"`
}
type Track ¶
type Track struct {
MediaID *uuid.UUID `json:"media_id" db:"media_id,pk,unique"`
Name string `json:"name" db:"name"`
Artists mo.Either[[]Person, []Group] `json:"artists" db:"artists"`
Duration time.Duration `json:"duration" db:"duration"`
Lyrics string `json:"lyrics,omitempty" db:"lyrics"`
Languages []string `json:"languages,omitempty" db:"languages"`
}
type TrackRating ¶
type UpdateableKeyTypes ¶
type Venue ¶
type Venue struct {
UUID uuid.UUID `json:"uuid" db:"uuid,pk"`
Name string `json:"name" db:"name"`
Active bool `json:"active" db:"active"`
Street string `json:"street" db:"street"`
Zip string `json:"zip" db:"zip"`
Unit string `json:"unit" db:"unit"`
City *City `json:"city" db:"city"`
Country *Country `json:"country" db:"country"`
}
Click to show internal directories.
Click to hide internal directories.