query

package
v0.0.0-...-15592ba Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package query loads songs and tags from datastore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanSong

func CleanSong(s *db.Song, id int64)

CleanSong prepares s to be returned in results. This is exported so it can be called by tests in other packages.

func FlushCache

func FlushCache(ctx context.Context, t cache.Type) error

FlushCache deletes all cached queries and tags from t.

func FlushCacheForUpdate

func FlushCacheForUpdate(ctx context.Context, ut UpdateTypes) error

FlushCacheForUpdate deletes the appropriate cached queries for an update of the supplied types.

func Songs

func Songs(ctx context.Context, query *SongQuery, flags SongsFlags) ([]*db.Song, error)

Songs executes the supplied query and returns matching songs.

func Tags

func Tags(ctx context.Context, requireCache bool) ([]string, error)

Tags returns the full set of tags present across all songs. It attempts to return cached data before falling back to scanning all songs. If songs are scanned, the resulting tags are cached. If requireCache is true, an error is returned if tags aren't cached.

Types

type SongQuery

type SongQuery struct {
	Artist   string // Song.Artist
	Title    string // Song.Title
	Album    string // Song.Album
	AlbumID  string // Song.AlbumID
	Filename string // song.Filename

	Keywords []string // Song.Keywords

	Rating    int  // Song.Rating (0 if unspecified; use Unrated for 0)
	MinRating int  // Song.Rating (0 if unspecified)
	MaxRating int  // Song.Rating (0 if unspecified)
	Unrated   bool // Song.Rating is 0

	MaxPlays int64 // Song.NumPlays (-1 if unspecified)

	MinFirstStartTime time.Time // Song.FirstStartTime
	MaxLastStartTime  time.Time // Song.LastStartTime

	Track int64 // Song.Track
	Disc  int64 // Song.Disc

	MinDate time.Time // Song.Date
	MaxDate time.Time // Song.Date

	Tags    []string // present in Song.Tags
	NotTags []string // not present in Song.Tags

	Shuffle              bool // randomize results set/order
	OrderByLastStartTime bool // order by Song.LastStartTime
}

SongQuery describes a query returning a list of Songs.

type SongsFlags

type SongsFlags uint32

SongsFlags is a bitfield controlling the behavior of the Songs function.

const (
	// CacheOnly indicates that empty results should be returned if the query's results aren't
	// already cached.
	CacheOnly SongsFlags = 1 << iota
	// ForceFallback indicates that the fallback mode that tries to avoid requiring composite
	// indexes should be used instead of the normal mode.
	ForceFallback
	// NoFallback indicates that the fallback mode should never be used.
	NoFallback
)

type UpdateTypes

type UpdateTypes uint32

UpdateTypes is a bitfield describing what was changed by an update. It is used for invalidating cached data.

const (
	MetadataUpdate UpdateTypes = 1 << iota // song metadata
	RatingUpdate
	TagsUpdate
	PlaysUpdate
)

Jump to

Keyboard shortcuts

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