database

package
v1.45.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2024 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAPIRepo

func NewAPIRepo(log logger.Logger, db *DB) domain.APIRepo

func NewActionRepo

func NewActionRepo(log logger.Logger, db *DB, clientRepo domain.DownloadClientRepo) domain.ActionRepo

func NewClientCache

func NewClientCache() *clientCache

func NewDownloadClientRepo

func NewDownloadClientRepo(log logger.Logger, db *DB) domain.DownloadClientRepo

func NewFeedCacheRepo

func NewFeedCacheRepo(log logger.Logger, db *DB) domain.FeedCacheRepo

func NewFeedRepo

func NewFeedRepo(log logger.Logger, db *DB) domain.FeedRepo

func NewFilterRepo

func NewFilterRepo(log logger.Logger, db *DB) domain.FilterRepo

func NewIndexerRepo

func NewIndexerRepo(log logger.Logger, db *DB) domain.IndexerRepo

func NewIrcRepo

func NewIrcRepo(log logger.Logger, db *DB) domain.IrcRepo

func NewNotificationRepo

func NewNotificationRepo(log logger.Logger, db *DB) domain.NotificationRepo

func NewReleaseRepo

func NewReleaseRepo(log logger.Logger, db *DB) domain.ReleaseRepo

func NewUserRepo

func NewUserRepo(log logger.Logger, db *DB) domain.UserRepo

Types

type APIRepo

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

func (*APIRepo) Delete

func (r *APIRepo) Delete(ctx context.Context, key string) error

func (*APIRepo) GetKeys

func (r *APIRepo) GetKeys(ctx context.Context) ([]domain.APIKey, error)

func (*APIRepo) Store

func (r *APIRepo) Store(ctx context.Context, key *domain.APIKey) error

type ActionRepo

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

func (*ActionRepo) Delete

func (*ActionRepo) DeleteByFilterID

func (r *ActionRepo) DeleteByFilterID(ctx context.Context, filterID int) error

func (*ActionRepo) FindByFilterID

func (r *ActionRepo) FindByFilterID(ctx context.Context, filterID int, active *bool) ([]*domain.Action, error)

func (*ActionRepo) Get added in v1.26.0

func (*ActionRepo) List

func (r *ActionRepo) List(ctx context.Context) ([]domain.Action, error)

func (*ActionRepo) Store

func (r *ActionRepo) Store(ctx context.Context, action domain.Action) (*domain.Action, error)

func (*ActionRepo) StoreFilterActions

func (r *ActionRepo) StoreFilterActions(ctx context.Context, filterID int64, actions []*domain.Action) ([]*domain.Action, error)

func (*ActionRepo) ToggleEnabled

func (r *ActionRepo) ToggleEnabled(actionID int) error

func (*ActionRepo) Update

func (r *ActionRepo) Update(ctx context.Context, action domain.Action) (*domain.Action, error)

type DB

type DB struct {
	Driver string
	DSN    string
	// contains filtered or unexported fields
}

func NewDB

func NewDB(cfg *domain.Config, log logger.Logger) (*DB, error)

func (*DB) BeginTx

func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) ILike added in v1.34.0

func (db *DB) ILike(col string, val string) ILikeDynamic

ILike is a wrapper for sq.Like and sq.ILike SQLite does not support ILike but postgres does so this checks what database is being used

func (*DB) Open

func (db *DB) Open() error

func (*DB) Ping

func (db *DB) Ping() error

type DownloadClientRepo

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

func (*DownloadClientRepo) Delete

func (r *DownloadClientRepo) Delete(ctx context.Context, clientID int) error

func (*DownloadClientRepo) FindByID

func (*DownloadClientRepo) List

func (*DownloadClientRepo) Store

func (*DownloadClientRepo) Update

type FeedCacheRepo

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

func (*FeedCacheRepo) Delete

func (r *FeedCacheRepo) Delete(ctx context.Context, feedId int, key string) error

func (*FeedCacheRepo) DeleteByFeed added in v1.29.0

func (r *FeedCacheRepo) DeleteByFeed(ctx context.Context, feedId int) error

func (*FeedCacheRepo) DeleteStale added in v1.29.0

func (r *FeedCacheRepo) DeleteStale(ctx context.Context) error

func (*FeedCacheRepo) Exists

func (r *FeedCacheRepo) Exists(feedId int, key string) (bool, error)

func (*FeedCacheRepo) Get

func (r *FeedCacheRepo) Get(feedId int, key string) ([]byte, error)

func (*FeedCacheRepo) GetByFeed added in v1.29.0

func (r *FeedCacheRepo) GetByFeed(ctx context.Context, feedId int) ([]domain.FeedCacheItem, error)

func (*FeedCacheRepo) GetCountByFeed added in v1.29.0

func (r *FeedCacheRepo) GetCountByFeed(ctx context.Context, feedId int) (int, error)

func (*FeedCacheRepo) Put

func (r *FeedCacheRepo) Put(feedId int, key string, val []byte, ttl time.Time) error

func (*FeedCacheRepo) PutMany added in v1.32.0

func (r *FeedCacheRepo) PutMany(ctx context.Context, items []domain.FeedCacheItem) error

type FeedRepo

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

func (*FeedRepo) Delete

func (r *FeedRepo) Delete(ctx context.Context, id int) error

func (*FeedRepo) Find

func (r *FeedRepo) Find(ctx context.Context) ([]domain.Feed, error)

func (*FeedRepo) FindByID

func (r *FeedRepo) FindByID(ctx context.Context, id int) (*domain.Feed, error)

func (*FeedRepo) FindByIndexerIdentifier

func (r *FeedRepo) FindByIndexerIdentifier(ctx context.Context, indexer string) (*domain.Feed, error)

func (*FeedRepo) GetLastRunDataByID

func (r *FeedRepo) GetLastRunDataByID(ctx context.Context, id int) (string, error)

func (*FeedRepo) Store

func (r *FeedRepo) Store(ctx context.Context, feed *domain.Feed) error

func (*FeedRepo) ToggleEnabled

func (r *FeedRepo) ToggleEnabled(ctx context.Context, id int, enabled bool) error

func (*FeedRepo) Update

func (r *FeedRepo) Update(ctx context.Context, feed *domain.Feed) error

func (*FeedRepo) UpdateLastRun

func (r *FeedRepo) UpdateLastRun(ctx context.Context, feedID int) error

func (*FeedRepo) UpdateLastRunWithData

func (r *FeedRepo) UpdateLastRunWithData(ctx context.Context, feedID int, data string) error

type FilterRepo

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

func (*FilterRepo) Delete

func (r *FilterRepo) Delete(ctx context.Context, filterID int) error

func (*FilterRepo) DeleteFilterExternal added in v1.29.0

func (r *FilterRepo) DeleteFilterExternal(ctx context.Context, filterID int) error

func (*FilterRepo) DeleteIndexerConnections

func (r *FilterRepo) DeleteIndexerConnections(ctx context.Context, filterID int) error

func (*FilterRepo) Find

func (*FilterRepo) FindByID

func (r *FilterRepo) FindByID(ctx context.Context, filterID int) (*domain.Filter, error)

func (*FilterRepo) FindByIndexerIdentifier

func (r *FilterRepo) FindByIndexerIdentifier(ctx context.Context, indexer string) ([]*domain.Filter, error)

FindByIndexerIdentifier find active filters with active indexer only

func (*FilterRepo) FindExternalFiltersByID added in v1.29.0

func (r *FilterRepo) FindExternalFiltersByID(ctx context.Context, filterId int) ([]domain.FilterExternal, error)

func (*FilterRepo) GetDownloadsByFilterId

func (r *FilterRepo) GetDownloadsByFilterId(ctx context.Context, filterID int) (*domain.FilterDownloads, error)

GetDownloadsByFilterId looks up how many `PENDING` or `PUSH_APPROVED` releases there have been for the given filter in the current time window starting at the start of the unit (since the beginning of the most recent hour/day/week).

See also https://github.com/autobrr/autobrr/pull/1285#pullrequestreview-1795913581

func (*FilterRepo) ListFilters

func (r *FilterRepo) ListFilters(ctx context.Context) ([]domain.Filter, error)

func (*FilterRepo) Store

func (r *FilterRepo) Store(ctx context.Context, filter *domain.Filter) error

func (*FilterRepo) StoreFilterExternal added in v1.29.0

func (r *FilterRepo) StoreFilterExternal(ctx context.Context, filterID int, externalFilters []domain.FilterExternal) error

func (*FilterRepo) StoreIndexerConnection

func (r *FilterRepo) StoreIndexerConnection(ctx context.Context, filterID int, indexerID int) error

func (*FilterRepo) StoreIndexerConnections

func (r *FilterRepo) StoreIndexerConnections(ctx context.Context, filterID int, indexers []domain.Indexer) error

func (*FilterRepo) ToggleEnabled

func (r *FilterRepo) ToggleEnabled(ctx context.Context, filterID int, enabled bool) error

func (*FilterRepo) Update

func (r *FilterRepo) Update(ctx context.Context, filter *domain.Filter) error

func (*FilterRepo) UpdatePartial

func (r *FilterRepo) UpdatePartial(ctx context.Context, filter domain.FilterUpdate) error

type ILikeDynamic

type ILikeDynamic interface {
	ToSql() (sql string, args []interface{}, err error)
}

type IndexerRepo

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

func (*IndexerRepo) Delete

func (r *IndexerRepo) Delete(ctx context.Context, id int) error

func (*IndexerRepo) FindByFilterID

func (r *IndexerRepo) FindByFilterID(ctx context.Context, id int) ([]domain.Indexer, error)

func (*IndexerRepo) FindByID

func (r *IndexerRepo) FindByID(ctx context.Context, id int) (*domain.Indexer, error)

func (*IndexerRepo) GetBy added in v1.45.0

func (*IndexerRepo) List

func (r *IndexerRepo) List(ctx context.Context) ([]domain.Indexer, error)

func (*IndexerRepo) Store

func (r *IndexerRepo) Store(ctx context.Context, indexer domain.Indexer) (*domain.Indexer, error)

func (*IndexerRepo) ToggleEnabled added in v1.32.0

func (r *IndexerRepo) ToggleEnabled(ctx context.Context, indexerID int, enabled bool) error

func (*IndexerRepo) Update

func (r *IndexerRepo) Update(ctx context.Context, indexer domain.Indexer) (*domain.Indexer, error)

type IrcRepo

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

func (*IrcRepo) CheckExistingNetwork

func (r *IrcRepo) CheckExistingNetwork(ctx context.Context, network *domain.IrcNetwork) (*domain.IrcNetwork, error)

func (*IrcRepo) DeleteNetwork

func (r *IrcRepo) DeleteNetwork(ctx context.Context, id int64) error

func (*IrcRepo) FindActiveNetworks

func (r *IrcRepo) FindActiveNetworks(ctx context.Context) ([]domain.IrcNetwork, error)

func (*IrcRepo) GetNetworkByID

func (r *IrcRepo) GetNetworkByID(ctx context.Context, id int64) (*domain.IrcNetwork, error)

func (*IrcRepo) ListChannels

func (r *IrcRepo) ListChannels(networkID int64) ([]domain.IrcChannel, error)

func (*IrcRepo) ListNetworks

func (r *IrcRepo) ListNetworks(ctx context.Context) ([]domain.IrcNetwork, error)

func (*IrcRepo) StoreChannel

func (r *IrcRepo) StoreChannel(ctx context.Context, networkID int64, channel *domain.IrcChannel) error

func (*IrcRepo) StoreNetwork

func (r *IrcRepo) StoreNetwork(ctx context.Context, network *domain.IrcNetwork) error

func (*IrcRepo) StoreNetworkChannels

func (r *IrcRepo) StoreNetworkChannels(ctx context.Context, networkID int64, channels []domain.IrcChannel) error

func (*IrcRepo) UpdateChannel

func (r *IrcRepo) UpdateChannel(channel *domain.IrcChannel) error

func (*IrcRepo) UpdateInviteCommand

func (r *IrcRepo) UpdateInviteCommand(networkID int64, invite string) error

func (*IrcRepo) UpdateNetwork

func (r *IrcRepo) UpdateNetwork(ctx context.Context, network *domain.IrcNetwork) error

type NotificationRepo

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

func (*NotificationRepo) Delete

func (r *NotificationRepo) Delete(ctx context.Context, notificationID int) error

func (*NotificationRepo) Find

func (*NotificationRepo) FindByID

func (r *NotificationRepo) FindByID(ctx context.Context, id int) (*domain.Notification, error)

func (*NotificationRepo) List

func (*NotificationRepo) Store

func (r *NotificationRepo) Store(ctx context.Context, notification domain.Notification) (*domain.Notification, error)

func (*NotificationRepo) Update

func (r *NotificationRepo) Update(ctx context.Context, notification domain.Notification) (*domain.Notification, error)

type ReleaseRepo

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

func (*ReleaseRepo) CheckSmartEpisodeCanDownload added in v1.43.0

func (repo *ReleaseRepo) CheckSmartEpisodeCanDownload(ctx context.Context, p *domain.SmartEpisodeParams) (bool, error)

func (*ReleaseRepo) Delete

func (repo *ReleaseRepo) Delete(ctx context.Context, req *domain.DeleteReleaseRequest) error

func (*ReleaseRepo) Find

func (*ReleaseRepo) FindRecent

func (repo *ReleaseRepo) FindRecent(ctx context.Context) ([]*domain.Release, error)

func (*ReleaseRepo) Get added in v1.26.0

func (*ReleaseRepo) GetActionStatus added in v1.26.0

func (*ReleaseRepo) GetActionStatusByReleaseID

func (repo *ReleaseRepo) GetActionStatusByReleaseID(ctx context.Context, releaseID int64) ([]domain.ReleaseActionStatus, error)

func (*ReleaseRepo) GetIndexerOptions

func (repo *ReleaseRepo) GetIndexerOptions(ctx context.Context) ([]string, error)

func (*ReleaseRepo) Stats

func (repo *ReleaseRepo) Stats(ctx context.Context) (*domain.ReleaseStats, error)

func (*ReleaseRepo) Store

func (repo *ReleaseRepo) Store(ctx context.Context, r *domain.Release) error

func (*ReleaseRepo) StoreReleaseActionStatus

func (repo *ReleaseRepo) StoreReleaseActionStatus(ctx context.Context, status *domain.ReleaseActionStatus) error

func (*ReleaseRepo) UpdateBaseURL added in v1.42.0

func (repo *ReleaseRepo) UpdateBaseURL(ctx context.Context, indexer string, oldBaseURL, newBaseURL string) error

type Tx

type Tx struct {
	*sql.Tx
	// contains filtered or unexported fields
}

type UserRepo

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

func (*UserRepo) Delete added in v1.34.0

func (r *UserRepo) Delete(ctx context.Context, username string) error

func (*UserRepo) FindByUsername

func (r *UserRepo) FindByUsername(ctx context.Context, username string) (*domain.User, error)

func (*UserRepo) GetUserCount

func (r *UserRepo) GetUserCount(ctx context.Context) (int, error)

func (*UserRepo) Store

func (*UserRepo) Update

func (r *UserRepo) Update(ctx context.Context, user domain.UpdateUserRequest) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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