Documentation
¶
Overview ¶
package db defines the database interface
Index ¶
- Constants
- func ListenActivityOptsToTimes(opts ListenActivityOpts) (start, end time.Time)
- func StartTimeFromPeriod(p Period) time.Time
- type AddArtistsToAlbumOpts
- type DB
- type ExportItem
- type GetAlbumOpts
- type GetArtistOpts
- type GetExportPageOpts
- type GetItemsOpts
- type GetTrackOpts
- type InformationSource
- type ListenActivityItem
- type ListenActivityOpts
- type PaginatedResponse
- type Period
- type SaveAlbumOpts
- type SaveApiKeyOpts
- type SaveArtistOpts
- type SaveListenOpts
- type SaveTrackOpts
- type SaveUserOpts
- type StepInterval
- type TimeListenedOpts
- type UpdateAlbumOpts
- type UpdateApiKeyLabelOpts
- type UpdateArtistMetadataParams
- type UpdateArtistOpts
- type UpdateReleaseMetadataParams
- type UpdateTrackMetadataParams
- type UpdateTrackOpts
- type UpdateUserOpts
Constants ¶
View Source
const ( StepDay StepInterval = "day" StepWeek StepInterval = "week" StepMonth StepInterval = "month" StepYear StepInterval = "year" StepDefault StepInterval = "day" DefaultRange int = 12 )
Variables ¶
This section is empty.
Functions ¶
func ListenActivityOptsToTimes ¶
func ListenActivityOptsToTimes(opts ListenActivityOpts) (start, end time.Time)
start is the time of 00:00 at the beginning of opts.Range opts.Steps ago, end is the end time of the current opts.Step. E.g. if step is StepWeek and range is 4, start will be the time 00:00 on Sunday on the 4th week ago, and end will be 23:59:59 on Saturday at the end of the current week. If opts.Year (or opts.Year + opts.Month) is provided, start and end will simply by the start and end times of that year/month.
func StartTimeFromPeriod ¶
Types ¶
type AddArtistsToAlbumOpts ¶
type DB ¶
type DB interface {
// Get
GetArtist(ctx context.Context, opts GetArtistOpts) (*models.Artist, error)
GetAlbum(ctx context.Context, opts GetAlbumOpts) (*models.Album, error)
GetTrack(ctx context.Context, opts GetTrackOpts) (*models.Track, error)
GetArtistsForAlbum(ctx context.Context, id int32) ([]*models.Artist, error)
GetArtistsForTrack(ctx context.Context, id int32) ([]*models.Artist, error)
GetTopTracksPaginated(ctx context.Context, opts GetItemsOpts) (*PaginatedResponse[*models.Track], error)
GetTopArtistsPaginated(ctx context.Context, opts GetItemsOpts) (*PaginatedResponse[*models.Artist], error)
GetTopAlbumsPaginated(ctx context.Context, opts GetItemsOpts) (*PaginatedResponse[*models.Album], error)
GetListensPaginated(ctx context.Context, opts GetItemsOpts) (*PaginatedResponse[*models.Listen], error)
GetListenActivity(ctx context.Context, opts ListenActivityOpts) ([]ListenActivityItem, error)
GetAllArtistAliases(ctx context.Context, id int32) ([]models.Alias, error)
GetAllAlbumAliases(ctx context.Context, id int32) ([]models.Alias, error)
GetAllTrackAliases(ctx context.Context, id int32) ([]models.Alias, error)
GetApiKeysByUserID(ctx context.Context, id int32) ([]models.ApiKey, error)
GetUserBySession(ctx context.Context, sessionId uuid.UUID) (*models.User, error)
GetUserByUsername(ctx context.Context, username string) (*models.User, error)
GetUserByApiKey(ctx context.Context, key string) (*models.User, error)
GetUser(ctx context.Context, id int32) (*models.User, error)
// Save
SaveArtist(ctx context.Context, opts SaveArtistOpts) (*models.Artist, error)
SaveArtistAliases(ctx context.Context, id int32, aliases []string, source string) error
SaveAlbum(ctx context.Context, opts SaveAlbumOpts) (*models.Album, error)
SaveAlbumAliases(ctx context.Context, id int32, aliases []string, source string) error
SaveTrack(ctx context.Context, opts SaveTrackOpts) (*models.Track, error)
SaveTrackAliases(ctx context.Context, id int32, aliases []string, source string) error
SaveListen(ctx context.Context, opts SaveListenOpts) error
SaveUser(ctx context.Context, opts SaveUserOpts) (*models.User, error)
SaveApiKey(ctx context.Context, opts SaveApiKeyOpts) (*models.ApiKey, error)
SaveSession(ctx context.Context, userId int32, expiresAt time.Time, persistent bool) (*models.Session, error)
// Update
UpdateArtist(ctx context.Context, opts UpdateArtistOpts) error
UpdateArtistMetadata(ctx context.Context, opts UpdateArtistMetadataParams) error
UpdateTrack(ctx context.Context, opts UpdateTrackOpts) error
UpdateTrackMetadata(ctx context.Context, opts UpdateTrackMetadataParams) error
UpdateAlbum(ctx context.Context, opts UpdateAlbumOpts) error
UpdateReleaseMetadata(ctx context.Context, opts UpdateReleaseMetadataParams) error
AddArtistsToAlbum(ctx context.Context, opts AddArtistsToAlbumOpts) error
UpdateUser(ctx context.Context, opts UpdateUserOpts) error
UpdateApiKeyLabel(ctx context.Context, opts UpdateApiKeyLabelOpts) error
RefreshSession(ctx context.Context, sessionId uuid.UUID, expiresAt time.Time) error
SetPrimaryArtistAlias(ctx context.Context, id int32, alias string) error
SetPrimaryAlbumAlias(ctx context.Context, id int32, alias string) error
SetPrimaryTrackAlias(ctx context.Context, id int32, alias string) error
SetPrimaryAlbumArtist(ctx context.Context, id int32, artistId int32, value bool) error
SetPrimaryTrackArtist(ctx context.Context, id int32, artistId int32, value bool) error
// Delete
DeleteArtist(ctx context.Context, id int32) error
DeleteAlbum(ctx context.Context, id int32) error
DeleteTrack(ctx context.Context, id int32) error
DeleteListen(ctx context.Context, trackId int32, listenedAt time.Time, userId int32) error
DeleteArtistAlias(ctx context.Context, id int32, alias string) error
DeleteAlbumAlias(ctx context.Context, id int32, alias string) error
DeleteTrackAlias(ctx context.Context, id int32, alias string) error
DeleteSession(ctx context.Context, sessionId uuid.UUID) error
DeleteApiKey(ctx context.Context, id int32, userID int32) error
// Count
CountListens(ctx context.Context, userID int32, period Period) (int64, error)
CountTracks(ctx context.Context, userID int32, period Period) (int64, error)
CountAlbums(ctx context.Context, userID int32, period Period) (int64, error)
CountArtists(ctx context.Context, userID int32, period Period) (int64, error)
CountTimeListened(ctx context.Context, userID int32, period Period) (int64, error)
CountTimeListenedToItem(ctx context.Context, opts TimeListenedOpts) (int64, error)
CountUsers(ctx context.Context) (int64, error)
// Search
SearchArtists(ctx context.Context, q string) ([]*models.Artist, error)
SearchAlbums(ctx context.Context, q string) ([]*models.Album, error)
SearchTracks(ctx context.Context, q string) ([]*models.Track, error)
// Merge
MergeTracks(ctx context.Context, fromId, toId int32) error
MergeAlbums(ctx context.Context, fromId, toId int32, replaceImage bool) error
MergeArtists(ctx context.Context, fromId, toId int32, replaceImage bool) error
// Etc
ImageHasAssociation(ctx context.Context, image uuid.UUID) (bool, error)
GetImageSource(ctx context.Context, image uuid.UUID) (string, error)
GetAlbumByImage(ctx context.Context, image uuid.UUID) (*models.Album, error)
GetArtistByImage(ctx context.Context, image uuid.UUID) (*models.Artist, error)
AlbumsWithoutImages(ctx context.Context, from int32) ([]*models.Album, error)
GetExportPage(ctx context.Context, opts GetExportPageOpts) ([]*ExportItem, error)
// Theme
SaveUserTheme(ctx context.Context, userId int32, themeData []byte) error
GetUserTheme(ctx context.Context, userId int32) ([]byte, error)
// Preferences
SaveUserPreferences(ctx context.Context, userId int32, preferencesData []byte) error
GetUserPreferences(ctx context.Context, userId int32) ([]byte, error)
// Sources
UpsertClientSource(ctx context.Context, userId int32, name, token string) error
GetClientSources(ctx context.Context, userId int32) ([]models.ClientSource, error)
// User
GetAllUsers(ctx context.Context) ([]*models.User, error)
DeleteUser(ctx context.Context, id int32) error
ExistsListenFuzzy(ctx context.Context, arg repository.ExistsListenFuzzyParams) (bool, error)
// Lifecycle
Ping(ctx context.Context) error
Close(ctx context.Context)
}
type ExportItem ¶
type ExportItem struct {
ListenedAt time.Time
UserID int32
Client *string
TrackID int32
TrackMbid *uuid.UUID
TrackDuration int32
TrackAliases []models.Alias
ReleaseID int32
ReleaseMbid *uuid.UUID
ReleaseImage *uuid.UUID
ReleaseImageSource string
VariousArtists bool
ReleaseAliases []models.Alias
Artists []models.ArtistWithFullAliases
}
type GetAlbumOpts ¶
type GetArtistOpts ¶
type GetExportPageOpts ¶
type GetItemsOpts ¶
type GetTrackOpts ¶
type InformationSource ¶
type InformationSource string
const ( InformationSourceInferred InformationSource = "Inferred" InformationSourceMusicBrainz InformationSource = "MusicBrainz" InformationSourceUserProvided InformationSource = "User" )
type ListenActivityItem ¶
type ListenActivityOpts ¶
type PaginatedResponse ¶
type SaveAlbumOpts ¶
type SaveApiKeyOpts ¶
type SaveArtistOpts ¶
type SaveListenOpts ¶
type SaveTrackOpts ¶
type SaveUserOpts ¶
type StepInterval ¶
type StepInterval string
type TimeListenedOpts ¶
type UpdateAlbumOpts ¶
type UpdateApiKeyLabelOpts ¶
type UpdateArtistMetadataParams ¶ added in v0.1.30
type UpdateArtistOpts ¶
type UpdateReleaseMetadataParams ¶ added in v0.1.30
type UpdateTrackMetadataParams ¶ added in v0.1.30
type UpdateTrackMetadataParams struct {
ID int32
Popularity pgtype.Int4
SpotifyID pgtype.Text
Danceability pgtype.Float8
Energy pgtype.Float8
Key pgtype.Int4
Loudness pgtype.Float8
Mode pgtype.Int4
Speechiness pgtype.Float8
Acousticness pgtype.Float8
Instrumentalness pgtype.Float8
Liveness pgtype.Float8
Valence pgtype.Float8
Tempo pgtype.Float8
}
type UpdateTrackOpts ¶
Click to show internal directories.
Click to hide internal directories.