db

package
v0.0.0-...-e1ec090 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPrivacy = 5

Possible values - PRIVATE (1) - DISCORD (2) - FMUSERNAME (3) - BOTH (4) - UNSET (5) - used for displaying help messages for people who haven't set it

Variables

View Source
var Db *pg.DB

Db holds a database reference

Functions

func ConvertPrivacyFromString

func ConvertPrivacyFromString(privacy string) int64

func ConvertPrivacyToString

func ConvertPrivacyToString(privacy int64) string

func InitDB

func InitDB()

InitDB initializes the database

Types

type Album

type Album struct {
	ID   int64 `pg:",pk"`
	Name string

	ArtistID int64
	Artist   *Artist `pg:"rel:has-one"`
}

Album represents a cached artist

type AlbumCount

type AlbumCount struct {
	ID        int64 `pg:",pk"`
	Playcount int32

	UserID int64
	User   *User `pg:"rel:has-one"`

	AlbumID int64
	Album   *Album `pg:"rel:has-one"`
}

AlbumCount represents aggregated album plays

type Artist

type Artist struct {
	ID             int64 `pg:",pk"`
	Name           string
	CheckedForTags bool

	Tags []Tag `pg:"many2many:artist_tags"`
}

Artist represents a cached artist

type ArtistCount

type ArtistCount struct {
	ID        int64 `pg:",pk"`
	Playcount int32

	UserID int64
	User   *User `pg:"rel:has-one"`

	ArtistID int64
	Artist   *Artist `pg:"rel:has-one"`
}

ArtistCount represents aggregated artist plays

type ArtistTag

type ArtistTag struct {
	ArtistID int64
	Artist   *Artist `pg:"rel:has-one"`

	TagID int64
	Tag   *Tag `pg:"rel:has-one"`
}

type GuildMember

type GuildMember struct {
	GuildID string

	User   *User `pg:"rel:has-one"`
	UserID int64
}

GuildMember represents a discord user in a guild

type Logger

type Logger struct{}

Logger logs queries when they are run

func (Logger) AfterQuery

func (d Logger) AfterQuery(c context.Context, q *pg.QueryEvent) error

AfterQuery runs after a query is executed

func (Logger) BeforeQuery

func (d Logger) BeforeQuery(c context.Context, q *pg.QueryEvent) (context.Context, error)

BeforeQuery runs before a query is executed

type RateYourMusicAlbum

type RateYourMusicAlbum struct {
	ID              int64 `pg:",pk"`
	RateYourMusicID string
	ReleaseYear     *int

	Title            string
	ArtistName       string
	ArtistNativeName *string

	Albums []Album `pg:"many2many:rate_your_music_album_albums"`
}

type RateYourMusicAlbumAlbum

type RateYourMusicAlbumAlbum struct {
	RateYourMusicAlbumID int64
	RateYourMusicAlbum   *RateYourMusicAlbum `pg:"rel:has-one"`

	AlbumID int64
	Album   *Album `pg:"rel:has-one"`
}

type Rating

type Rating struct {
	ID     int `pg:",pk"`
	Rating int

	UserID int64
	User   *User `pg:"rel:has-one"`

	RateYourMusicAlbumID int64
	RateYourMusicAlbum   *RateYourMusicAlbum `pg:"rel:has-one"`
}

Rating represents a single user's rating from rateyourmusic

type Scrobble

type Scrobble struct {
	ID          int64 `pg:",pk"`
	ScrobbledAt time.Time

	UserID int64
	User   *User `pg:"rel:has-one"`

	TrackID int64
	Track   *Track `pg:"rel:has-one"`

	ArtistID int64
	Artist   *Artist `pg:"rel:has-one"`

	AlbumID int64
	Album   *Album `pg:"rel:has-one"`
}

Scrobble represents a single play of a song (eg. a Last.fm scrobble)

type Tag

type Tag struct {
	ID   int64 `pg:",pk"`
	Name string

	Artists []Artist `pg:"many2many:artist_tags"`
}

type Track

type Track struct {
	ID   int64 `pg:",pk"`
	Name string

	ArtistID int64
	Artist   *Artist `pg:"rel:has-one"`

	AlbumID *int64
	Album   *Album `pg:"rel:has-one"`
}

Track represents a cached artist

type TrackCount

type TrackCount struct {
	ID        int64 `pg:",pk"`
	Playcount int32

	UserID int64
	User   *User `pg:"rel:has-one"`

	TrackID int64
	Track   *Track `pg:"rel:has-one"`
}

TrackCount represents aggregated track plays

type User

type User struct {
	ID            int64 `pg:",pk"`
	DiscordID     string
	Username      string
	LastIndexed   time.Time
	LastFMSession *string
	Privacy       int64

	GuildMembers *[]GuildMember `pg:"rel:has-many"`
}

User is the database model for a last.fm user

func (User) AsRequestable

func (u User) AsRequestable() lastfm.Requestable

func (User) SetLastIndexed

func (u User) SetLastIndexed(to time.Time)

SetLastIndexed sets a user's last indexed time

Jump to

Keyboard shortcuts

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