mariadb

package
v0.0.0-...-fd00b2c Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const FavePriorityIncrement = 1

FavePriorityIncrement is the amount we increase/decrease priority by on a track when it gets favorited/unfavorited

Variables

View Source
var DatabaseConnectFunc = sqlx.ConnectContext

Functions

func Connect

func Connect(ctx context.Context, cfg config.Config) (radio.StorageService, error)

Connect connects to the database configured in cfg

func ConnectDB

func ConnectDB(ctx context.Context, cfg config.Config, multistatement bool) (*sqlx.DB, error)

ConnectDB connects to the configured mariadb instance and returns the raw database object. Argument multistatement indicates if we should allow queries with multiple statements in them.

func IsDuplicateKeyErr

func IsDuplicateKeyErr(err error) bool

func MatchName

func MatchName(regex, name string) bool

func ProcessQuery

func ProcessQuery(q string) string

func SplitQuery

func SplitQuery(q string) []string

Types

type NewsStorage

type NewsStorage struct {
	// contains filtered or unexported fields
}

NewsStorage implements radio.NewsStorage

func (NewsStorage) Comments

func (ns NewsStorage) Comments(postid radio.NewsPostID) ([]radio.NewsComment, error)

Comments implements radio.NewsStorage

func (NewsStorage) CommentsPublic

func (ns NewsStorage) CommentsPublic(postid radio.NewsPostID) ([]radio.NewsComment, error)

CommentsPublic implements radio.NewsStorage

func (NewsStorage) Create

func (ns NewsStorage) Create(post radio.NewsPost) (radio.NewsPostID, error)

Create implements radio.NewsStorage

func (NewsStorage) Delete

func (ns NewsStorage) Delete(id radio.NewsPostID) error

Delete implements radio.NewsStorage

func (NewsStorage) Get

Get implements radio.NewsStorage

func (NewsStorage) List

func (ns NewsStorage) List(limit int64, offset int64) (radio.NewsList, error)

List implements radio.NewsStorage

func (NewsStorage) ListPublic

func (ns NewsStorage) ListPublic(limit int64, offset int64) (radio.NewsList, error)

ListPublic implements radio.NewsStorage

func (NewsStorage) Update

func (ns NewsStorage) Update(post radio.NewsPost) error

Update implements radio.NewsStorage

type QueueStorage

type QueueStorage struct {
	// contains filtered or unexported fields
}

QueueStorage is a radio.QueueStorage backed by a sql database

func (QueueStorage) Load

func (qs QueueStorage) Load(name string) ([]radio.QueueEntry, error)

Load loads the queue name given from the database configured

Implements radio.QueueStorage

func (QueueStorage) Store

func (qs QueueStorage) Store(name string, queue []radio.QueueEntry) error

Store stores the queue given under name in the database configured

Implements radio.QueueStorage

type RelayStorage

type RelayStorage struct {
	// contains filtered or unexported fields
}

RelayStorage implements radio.RelayStorage

func (RelayStorage) All

func (rs RelayStorage) All() ([]radio.Relay, error)

All implements radio.SessionStorage

func (RelayStorage) Update

func (rs RelayStorage) Update(r radio.Relay) error

Update implements radio.RelayStorage

type RequestStorage

type RequestStorage struct {
	// contains filtered or unexported fields
}

RequestStorage implements radio.RequestStorage

func (RequestStorage) LastRequest

func (rs RequestStorage) LastRequest(identifier string) (time.Time, error)

LastRequest implements radio.RequestStorage

func (RequestStorage) UpdateLastRequest

func (rs RequestStorage) UpdateLastRequest(identifier string) error

UpdateLastRequest implements radio.RequestStorage

type ScheduleStorage

type ScheduleStorage struct {
	// contains filtered or unexported fields
}

func (ScheduleStorage) History

func (ss ScheduleStorage) History(day radio.ScheduleDay, limit, offset int64) ([]radio.ScheduleEntry, error)

func (ScheduleStorage) Latest

func (ss ScheduleStorage) Latest() ([]*radio.ScheduleEntry, error)

func (ScheduleStorage) Update

func (ss ScheduleStorage) Update(entry radio.ScheduleEntry) error

type SearchService

type SearchService struct {
	// contains filtered or unexported fields
}

func (SearchService) Delete

func (SearchService) Search

func (ss SearchService) Search(ctx context.Context, search_query string, limit int64, offset int64) (*radio.SearchResult, error)

func (SearchService) Update

func (ss SearchService) Update(context.Context, ...radio.Song) error

type SessionStorage

type SessionStorage struct {
	// contains filtered or unexported fields
}

SessionStorage implements radio.SessionStorage

func (SessionStorage) Delete

func (ss SessionStorage) Delete(token radio.SessionToken) error

Delete implements radio.SessionStorage

func (SessionStorage) Get

Get implements radio.SessionStorage

func (SessionStorage) Save

func (ss SessionStorage) Save(session radio.Session) error

Save implements radio.SessionStorage

type SongStorage

type SongStorage struct {
	// contains filtered or unexported fields
}

SongStorage implements radio.SongStorage

func (SongStorage) AddFavorite

func (ss SongStorage) AddFavorite(song radio.Song, nick string) (bool, error)

AddFavorite implements radio.SongStorage

func (SongStorage) AddPlay

func (ss SongStorage) AddPlay(song radio.Song, user radio.User, ldiff *radio.Listeners) error

AddPlay implements radio.SongStorage

func (SongStorage) Create

func (ss SongStorage) Create(song radio.Song) (*radio.Song, error)

Create implements radio.SongStorage

func (SongStorage) FavoriteCount

func (ss SongStorage) FavoriteCount(song radio.Song) (int64, error)

FavoriteCount implements radio.SongStorage

func (SongStorage) Favorites

func (ss SongStorage) Favorites(song radio.Song) ([]string, error)

Favorites implements radio.SongStorage

func (SongStorage) FavoritesOf

func (ss SongStorage) FavoritesOf(nick string, limit, offset int64) ([]radio.Song, error)

FavoritesOf implements radio.SongStorage

func (SongStorage) FromHash

func (ss SongStorage) FromHash(hash radio.SongHash) (*radio.Song, error)

FromHash implements radio.SongStorage

func (SongStorage) FromMetadata

func (ss SongStorage) FromMetadata(metadata string) (*radio.Song, error)

FromMetadata implements radio.SongStorage

func (SongStorage) LastPlayed

func (ss SongStorage) LastPlayed(offset, amount int64) ([]radio.Song, error)

LastPlayed implements radio.SongStorage

func (SongStorage) LastPlayedCount

func (ss SongStorage) LastPlayedCount() (int64, error)

LastPlayedCount implements radio.SongStorage

func (SongStorage) PlayedCount

func (ss SongStorage) PlayedCount(song radio.Song) (int64, error)

PlayedCount implements radio.SongStorage

func (SongStorage) RemoveFavorite

func (ss SongStorage) RemoveFavorite(song radio.Song, nick string) (bool, error)

RemoveFavorite implements radio.SongStorage

func (ss SongStorage) UpdateHashLink(entry radio.SongHash, newLink radio.SongHash) error

func (SongStorage) UpdateLength

func (ss SongStorage) UpdateLength(song radio.Song, length time.Duration) error

UpdateLength implements radio.SongStorage

type StatusStorage

type StatusStorage struct {
	// contains filtered or unexported fields
}

func (StatusStorage) Load

func (ss StatusStorage) Load() (*radio.Status, error)

Load implements radio.StatusStorage

func (StatusStorage) Store

func (ss StatusStorage) Store(status radio.Status) error

Store implements radio.StatusStorage

type StorageService

type StorageService struct {
	// contains filtered or unexported fields
}

StorageService implements radio.StorageService with a sql database

func (*StorageService) News

func (*StorageService) NewsTx

func (*StorageService) Queue

func (*StorageService) QueueTx

func (*StorageService) Relay

func (*StorageService) RelayTx

func (*StorageService) Request

func (*StorageService) RequestTx

func (*StorageService) Schedule

func (*StorageService) ScheduleTx

func (*StorageService) Search

func (s *StorageService) Search() radio.SearchService

func (*StorageService) Sessions

func (*StorageService) SessionsTx

func (*StorageService) Song

func (*StorageService) SongTx

func (*StorageService) Status

func (*StorageService) Submissions

func (*StorageService) SubmissionsTx

func (*StorageService) Track

func (*StorageService) TrackTx

func (*StorageService) User

func (*StorageService) UserTx

type SubmissionStorage

type SubmissionStorage struct {
	// contains filtered or unexported fields
}

SubmissionStorage implements radio.SubmissionStorage

func (SubmissionStorage) All

func (ss SubmissionStorage) All() ([]radio.PendingSong, error)

func (SubmissionStorage) GetSubmission

func (ss SubmissionStorage) GetSubmission(id radio.SubmissionID) (*radio.PendingSong, error)

func (SubmissionStorage) InsertPostPending

func (ss SubmissionStorage) InsertPostPending(pend radio.PendingSong) error

func (SubmissionStorage) InsertSubmission

func (ss SubmissionStorage) InsertSubmission(song radio.PendingSong) error

func (SubmissionStorage) LastSubmissionTime

func (ss SubmissionStorage) LastSubmissionTime(identifier string) (time.Time, error)

LastSubmissionTime implements radio.SubmissionStorage

func (SubmissionStorage) RemoveSubmission

func (ss SubmissionStorage) RemoveSubmission(id radio.SubmissionID) error

func (SubmissionStorage) SubmissionStats

func (ss SubmissionStorage) SubmissionStats(identifier string) (radio.SubmissionStats, error)

func (SubmissionStorage) UpdateSubmissionTime

func (ss SubmissionStorage) UpdateSubmissionTime(identifier string) error

UpdateSubmissionTime implements radio.SubmissionStorage

type TrackStorage

type TrackStorage struct {
	// contains filtered or unexported fields
}

TrackStorage implements radio.TrackStorage

func (TrackStorage) All

func (ts TrackStorage) All() ([]radio.Song, error)

All implements radio.TrackStorage

func (TrackStorage) BeforeLastRequested

func (ts TrackStorage) BeforeLastRequested(before time.Time) ([]radio.Song, error)

BeforeLastRequested implements radio.TrackStorage

func (TrackStorage) DecrementRequestCount

func (ts TrackStorage) DecrementRequestCount(before time.Time) error

DecrementRequestCount implements radio.TrackStorage

func (TrackStorage) Delete

func (ts TrackStorage) Delete(id radio.TrackID) error

func (TrackStorage) Get

func (ts TrackStorage) Get(id radio.TrackID) (*radio.Song, error)

Get implements radio.TrackStorage

func (TrackStorage) Insert

func (ts TrackStorage) Insert(song radio.Song) (radio.TrackID, error)

func (TrackStorage) QueueCandidates

func (ts TrackStorage) QueueCandidates() ([]radio.TrackID, error)

QueueCandidates implements radio.TrackStorage

Candidates are returned based on their lastplayed and lastrequested values

func (TrackStorage) Unusable

func (ts TrackStorage) Unusable() ([]radio.Song, error)

Unusable implements radio.TrackStorage

func (TrackStorage) Update

func (ts TrackStorage) Update(song radio.Song) error

func (TrackStorage) UpdateLastPlayed

func (ts TrackStorage) UpdateLastPlayed(id radio.TrackID) error

UpdateLastPlayed implements radio.TrackStorage

func (TrackStorage) UpdateLastRequested

func (ts TrackStorage) UpdateLastRequested(id radio.TrackID) error

UpdateLastRequested implements radio.TrackStorage

func (TrackStorage) UpdateMetadata

func (ts TrackStorage) UpdateMetadata(song radio.Song) error

func (TrackStorage) UpdateRequestInfo

func (ts TrackStorage) UpdateRequestInfo(id radio.TrackID) error

UpdateRequestInfo updates the time the track given was last requested and increases the time between requests for the song.

implements radio.TrackStorage

func (TrackStorage) UpdateUsable

func (ts TrackStorage) UpdateUsable(song radio.Song, state radio.TrackState) error

type UserStorage

type UserStorage struct {
	// contains filtered or unexported fields
}

UserStorage implements radio.UserStorage

func (UserStorage) All

func (us UserStorage) All() ([]radio.User, error)

func (UserStorage) ByNick

func (us UserStorage) ByNick(nick string) (*radio.User, error)

ByNick implements radio.UserStorage

func (UserStorage) Get

func (us UserStorage) Get(name string) (*radio.User, error)

Get implements radio.UserStorage

func (UserStorage) GetByDJID

func (us UserStorage) GetByDJID(id radio.DJID) (*radio.User, error)

GetByDJID implements radio.UserStorage

func (UserStorage) GetByID

func (us UserStorage) GetByID(id radio.UserID) (*radio.User, error)

func (UserStorage) LookupName

func (us UserStorage) LookupName(name string) (*radio.User, error)

LookupName implements radio.UserStorage

func (UserStorage) Permissions

func (us UserStorage) Permissions() ([]radio.UserPermission, error)

Permissions implements radio.UserStorage

func (UserStorage) RecordListeners

func (us UserStorage) RecordListeners(listeners radio.Listeners, user radio.User) error

RecordListeners implements radio.UserStorage

func (UserStorage) UpdateUser

func (us UserStorage) UpdateUser(user radio.User) (radio.User, error)

UpdateUser implements radio.UserStorage

Jump to

Keyboard shortcuts

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