database

package
v0.0.0-...-7f3aa20 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureString

func EnsureString(src *string, dest *string)

func GetCategoryID

func GetCategoryID(dbs PGDBSession, name string) (int64, error)

func GetPlatformID

func GetPlatformID(dbs PGDBSession, name string) (int64, error)

func GetTagID

func GetTagID(dbs PGDBSession, name string) (int64, error)

func NewMysqlDAL

func NewMysqlDAL(conn *sql.DB) *mysqlDAL

func NewPostgresDAL

func NewPostgresDAL(conn *pgxpool.Pool) *postgresDAL

func OpenDB

func OpenDB(l *logrus.Entry, conf *config.Config) *sql.DB

OpenDB opens DAL or panics

func OpenPostgresDB

func OpenPostgresDB(l *logrus.Entry, conf *config.Config) *pgxpool.Pool

OpenPostgresDB opens DAL or panics

Types

type DAL

type DAL interface {
	NewSession(ctx context.Context) (DBSession, error)
	StoreSession(dbs DBSession, secret string, uid int64, durationSeconds int64, scope string, client string, ipAddr string) error
	DeleteSession(dbs DBSession, secret string) error
	GetSessions(dbs DBSession, uid int64) ([]*types.SessionInfo, error)
	GetSessionAuthInfo(dbs DBSession, secret string) (*types.SessionInfo, bool, error)
	RevokeSession(dbs DBSession, uid int64, sessionID int64) error

	SetClientSecret(dbs DBSession, clientID string, clientSecret string) error
	GetClientSecret(dbs DBSession, clientID string) (string, error)

	StoreDiscordUser(dbs DBSession, discordUser *types.DiscordUser) error
	GetDiscordUser(dbs DBSession, uid int64) (*types.DiscordUser, error)
	StoreDiscordServerRoles(dbs DBSession, roles []types.DiscordRole) error
	StoreDiscordUserRoles(dbs DBSession, uid int64, roles []int64) error
	GetDiscordUserRoles(dbs DBSession, uid int64) ([]string, error)

	StoreSubmission(dbs DBSession, submissionLevel string) (int64, error)
	StoreSubmissionFile(dbs DBSession, s *types.SubmissionFile) (int64, error)
	GetSubmissionFiles(dbs DBSession, sfids []int64) ([]*types.SubmissionFile, error)
	GetExtendedSubmissionFilesBySubmissionID(dbs DBSession, sid int64) ([]*types.ExtendedSubmissionFile, error)

	SearchSubmissions(dbs DBSession, filter *types.SubmissionsFilter) ([]*types.ExtendedSubmission, int64, error)

	StoreCurationMeta(dbs DBSession, cm *types.CurationMeta) error
	GetCurationMetaBySubmissionFileID(dbs DBSession, sfid int64) (*types.CurationMeta, error)

	StoreComment(dbs DBSession, c *types.Comment) error
	GetExtendedCommentsBySubmissionID(dbs DBSession, sid int64) ([]*types.ExtendedComment, error)
	GetCommentByID(dbs DBSession, cid int64) (*types.Comment, error)

	SoftDeleteSubmissionFile(dbs DBSession, sfid int64, deleteReason string) error
	SoftDeleteSubmission(dbs DBSession, sid int64, deleteReason string) error
	SoftDeleteComment(dbs DBSession, cid int64, deleteReason string) error

	StoreNotificationSettings(dbs DBSession, uid int64, actions []string) error
	GetNotificationSettingsByUserID(dbs DBSession, uid int64) ([]string, error)

	SubscribeUserToSubmission(dbs DBSession, uid, sid int64) error
	UnsubscribeUserFromSubmission(dbs DBSession, uid, sid int64) error
	IsUserSubscribedToSubmission(dbs DBSession, uid, sid int64) (bool, error)

	StoreNotification(dbs DBSession, msg, notificationType string) error
	GetUsersForNotification(dbs DBSession, authorID, sid int64, action string) ([]int64, error)
	GetUsersForUniversalNotification(dbs DBSession, authorID int64, action string) ([]int64, error)
	GetOldestUnsentNotification(dbs DBSession) (*types.Notification, error)
	MarkNotificationAsSent(dbs DBSession, nid int64) error

	StoreCurationImage(dbs DBSession, c *types.CurationImage) (int64, error)
	GetCurationImagesBySubmissionFileID(dbs DBSession, sfid int64) ([]*types.CurationImage, error)
	GetCurationImage(dbs DBSession, ciid int64) (*types.CurationImage, error)

	GetNextSubmission(dbs DBSession, sid int64) (int64, error)
	GetPreviousSubmission(dbs DBSession, sid int64) (int64, error)

	UpdateSubmissionCacheTable(dbs DBSession, sid int64) error

	ClearMasterDBGames(dbs DBSession) error
	StoreMasterDBGames(dbs DBSession, games []*types.MasterDatabaseGame) error

	GetAllSimilarityAttributes(dbs DBSession) ([]*types.SimilarityAttributes, error)

	StoreFlashfreezeRootFile(dbs DBSession, s *types.FlashfreezeFile) (int64, error)
	StoreFlashfreezeDeepFile(dbs DBSession, fid int64, entries []*types.IndexedFileEntry) error
	SearchFlashfreezeFiles(dbs DBSession, filter *types.FlashfreezeFilter) ([]*types.ExtendedFlashfreezeItem, int64, error)
	UpdateFlashfreezeRootFileIndexedState(dbs DBSession, fid int64, indexedAt *time.Time, indexingErrors uint64) error
	GetFlashfreezeRootFile(dbs DBSession, fid int64) (*types.FlashfreezeFile, error)
	GetAllFlashfreezeRootFiles(dbs DBSession) ([]*types.FlashfreezeFile, error)
	GetAllUnindexedFlashfreezeRootFiles(dbs DBSession) ([]*types.FlashfreezeFile, error)

	DeleteUserSessions(dbs DBSession, uid int64) (int64, error)

	GetTotalCommentsCount(dbs DBSession) (int64, error)
	GetTotalUserCount(dbs DBSession) (int64, error)
	GetTotalFlashfreezeCount(dbs DBSession) (int64, error)
	GetTotalFlashfreezeFileCount(dbs DBSession) (int64, error)
	GetTotalSubmissionFilesize(dbs DBSession) (int64, error)
	GetTotalFlashfreezeFilesize(dbs DBSession) (int64, error)

	GetUsers(dbs DBSession) ([]*types.User, error)
	GetCommentsByUserIDAndAction(dbs DBSession, uid int64, action string) ([]*types.Comment, error)

	PopulateRevisionInfo(dbs DBSession, revisions []*types.RevisionInfo) error

	FreezeSubmission(dbs DBSession, sid int64) error
	UnfreezeSubmission(dbs DBSession, sid int64) error

	NukeSessionTable(dbs DBSession) error

	UpdateSubmissionAutofreeze(dbs DBSession, sid int64, shouldAutofreeze bool) error
}

type DBSession

type DBSession interface {
	Commit() error
	Rollback() error
	Tx() *sql.Tx
	Ctx() context.Context
}

type MysqlSession

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

func (*MysqlSession) Commit

func (dbs *MysqlSession) Commit() error

func (*MysqlSession) Ctx

func (dbs *MysqlSession) Ctx() context.Context

func (*MysqlSession) Rollback

func (dbs *MysqlSession) Rollback() error

func (*MysqlSession) Tx

func (dbs *MysqlSession) Tx() *sql.Tx

type PGDAL

type PGDAL interface {
	NewSession(ctx context.Context) (PGDBSession, error)

	CountSinceDate(dbs PGDBSession, modifiedAfter *string) (int, error)

	SearchTags(dbs PGDBSession, modifiedAfter *string) ([]*types.Tag, error)
	SearchPlatforms(dbs PGDBSession, modifiedAfter *string) ([]*types.Platform, error)
	SearchGames(dbs PGDBSession, modifiedAfter *string, modifiedBefore *string, broad bool, afterId *string) ([]*types.Game, []*types.AdditionalApp, []*types.GameData, [][]string, [][]string, error)
	SearchDeletedGames(dbs PGDBSession, modifiedAfter *string) ([]*types.DeletedGame, error)

	GetTagCategories(dbs PGDBSession) ([]*types.TagCategory, error)
	GetGamesUsingTagTotal(dbs PGDBSession, tagId int64) (int64, error)
	SaveGame(dbs PGDBSession, game *types.Game, uid int64) error
	SaveGameData(dbs PGDBSession, gameId string, date int64, gameData *types.GameData) error
	SaveTag(dbs PGDBSession, tag *types.Tag, uid int64) error
	DeveloperImportDatabaseJson(dbs PGDBSession, data *types.LauncherDump) error

	GetTagCategory(dbs PGDBSession, categoryId int64) (*types.TagCategory, error)
	GetTag(dbs PGDBSession, tagId int64) (*types.Tag, error)
	GetTagByName(dbs PGDBSession, tagName string) (*types.Tag, error)
	GetPlatform(dbs PGDBSession, platformId int64) (*types.Platform, error)
	GetPlatformByName(dbs PGDBSession, platformName string) (*types.Platform, error)
	GetGames(dbs PGDBSession, gameIds []string) ([]*types.Game, error)
	GetGame(dbs PGDBSession, gameId string) (*types.Game, error)
	GetGameData(dbs PGDBSession, gameId string, date int64) (*types.GameData, error)
	GetGameDataIndex(dbs PGDBSession, gameId string, date int64) (*types.GameDataIndex, error)
	GetGameRevisionInfo(dbs PGDBSession, gameId string) ([]*types.RevisionInfo, error)
	GetTagRevisionInfo(dbs PGDBSession, tagId int64) ([]*types.RevisionInfo, error)

	GetMetadataStats(dbs PGDBSession) (*types.MetadataStatsPageDataBare, error)

	DeleteGame(dbs PGDBSession, gameId string, uid int64, reason string, imagesPath string, gamesPath string,
		deletedImagesPath string, deletedGamesPath string, frozenGamesPath string) error

	RestoreGame(dbs PGDBSession, gameId string, uid int64, reason string, imagesPath string, gamesPath string,
		deletedImagesPath string, deletedGamesPath string, frozenGamesPath string) error

	GetOrCreateTagCategory(dbs PGDBSession, categoryName string) (*types.TagCategory, error)
	GetOrCreateTag(dbs PGDBSession, tagName string, tagCategory string, reason string, uid int64) (*types.Tag, error)
	GetOrCreatePlatform(dbs PGDBSession, platformName string, reason string, uid int64) (*types.Platform, error)

	AddSubmissionFromValidator(dbs PGDBSession, uid int64, vr *types.ValidatorRepackResponse, frozen bool) (*types.Game, error)
	AddGameData(dbs PGDBSession, uid int64, gameId string, vr *types.ValidatorRepackResponse) (*types.GameData, error)

	IndexerGetNext(ctx context.Context) (*types.GameData, error)
	IndexerInsert(ctx context.Context, crc32sum []byte, md5sum []byte, sha256sum []byte, sha1sum []byte,
		size uint64, path string, gameId string, zipDate time.Time) error
	IndexerMarkFailure(ctx context.Context, gameId string, zipDate time.Time) error

	GetIndexMatchesHash(dbs PGDBSession, hashType string, hashStr string) ([]*types.IndexMatchData, error)

	UpdateTagsFromTagsList(dbs PGDBSession, tagsList []types.Tag) error
	ApplyGamePatch(dbs PGDBSession, uid int64, game *types.Game, patch *types.GameContentPatch, addApps []*types.CurationAdditionalApp) error
}

type PGDBSession

type PGDBSession interface {
	Commit() error
	Rollback() error
	Tx() pgx.Tx
	Ctx() context.Context
}

type PostgresSession

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

func (*PostgresSession) Commit

func (dbs *PostgresSession) Commit() error

func (*PostgresSession) Ctx

func (dbs *PostgresSession) Ctx() context.Context

func (*PostgresSession) Rollback

func (dbs *PostgresSession) Rollback() error

func (*PostgresSession) Tx

func (dbs *PostgresSession) Tx() pgx.Tx

Jump to

Keyboard shortcuts

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