Documentation
¶
Index ¶
- Variables
- func TxFromContext(ctx context.Context) (pgx.Tx, bool)
- func WithTx(ctx context.Context, tx pgx.Tx) context.Context
- type Querier
- type Storage
- func (s *Storage) AddRating(ctx context.Context, cr model.CreateRating) error
- func (s *Storage) BeginTx(ctx context.Context) (pgx.Tx, error)
- func (s *Storage) CreateCompany(ctx context.Context, c model.Company) (id int32, err error)
- func (s *Storage) CreateGame(ctx context.Context, cg model.CreateGameData) (id int32, err error)
- func (s *Storage) CreateGenre(ctx context.Context, g model.Genre) (id int32, err error)
- func (s *Storage) CreateModerationRecord(ctx context.Context, m model.CreateModeration) (id int32, err error)
- func (s *Storage) DeleteGame(ctx context.Context, id int32) error
- func (s *Storage) GetCompanies(ctx context.Context) (companies []model.Company, err error)
- func (s *Storage) GetCompanyByID(ctx context.Context, id int32) (company model.Company, err error)
- func (s *Storage) GetCompanyIDByName(ctx context.Context, name string) (id int32, err error)
- func (s *Storage) GetGameByID(ctx context.Context, id int32) (game model.Game, err error)
- func (s *Storage) GetGameIDByIGDBID(ctx context.Context, igdbID int64) (id int32, err error)
- func (s *Storage) GetGameTrendingData(ctx context.Context, gameID int32) (model.GameTrendingData, error)
- func (s *Storage) GetGames(ctx context.Context, pageSize, page uint32, filter model.GamesFilter) (list []model.Game, err error)
- func (s *Storage) GetGamesByPublisherID(ctx context.Context, publisherID int32) (list []model.Game, err error)
- func (s *Storage) GetGamesCount(ctx context.Context, filter model.GamesFilter) (count uint64, err error)
- func (s *Storage) GetGamesIDsAfterID(ctx context.Context, lastID int32, batchSize int) ([]int32, error)
- func (s *Storage) GetGenreByID(ctx context.Context, id int32) (genre model.Genre, err error)
- func (s *Storage) GetGenres(ctx context.Context) (genres []model.Genre, err error)
- func (s *Storage) GetModerationRecordByGameID(ctx context.Context, gameID int32) (m model.Moderation, err error)
- func (s *Storage) GetModerationRecordByID(ctx context.Context, id int32) (m model.Moderation, err error)
- func (s *Storage) GetModerationRecordsByGameID(ctx context.Context, gameID int32) (list []model.Moderation, err error)
- func (s *Storage) GetPendingModerationGameIDs(ctx context.Context, limit int) ([]model.ModerationIDGameID, error)
- func (s *Storage) GetPlatformByID(ctx context.Context, id int32) (platform model.Platform, err error)
- func (s *Storage) GetPlatforms(ctx context.Context) (platforms []model.Platform, err error)
- func (s *Storage) GetPublisherGamesCount(ctx context.Context, publisherID int32, startDate, endDate time.Time) (count int, err error)
- func (s *Storage) GetTask(ctx context.Context, name string) (task model.Task, err error)
- func (s *Storage) GetTopDevelopers(ctx context.Context, limit int64) (companies []model.Company, err error)
- func (s *Storage) GetTopGenres(ctx context.Context, limit int64) (genres []model.Genre, err error)
- func (s *Storage) GetTopPublishers(ctx context.Context, limit int64) (companies []model.Company, err error)
- func (s *Storage) GetUserRatings(ctx context.Context, userID string) (map[int32]uint8, error)
- func (s *Storage) GetUserRatingsByGamesIDs(ctx context.Context, userID string, gameIDs []int32) (ratings []model.UserRating, err error)
- func (s *Storage) RemoveRating(ctx context.Context, rr model.RemoveRating) error
- func (s *Storage) RunWithTx(ctx context.Context, f func(context.Context) error) error
- func (s *Storage) SetModerationRecordResultByGameID(ctx context.Context, gameID int32, result model.UpdateModerationResult) error
- func (s *Storage) SetModerationRecordsStatus(ctx context.Context, ids []int32, status model.ModerationStatus) error
- func (s *Storage) UpdateGame(ctx context.Context, id int32, ug model.UpdateGameData) error
- func (s *Storage) UpdateGameIGDBInfo(ctx context.Context, id int32, ug model.UpdateGameIGDBData) error
- func (s *Storage) UpdateGameModerationID(ctx context.Context, gameID, moderationID int32) error
- func (s *Storage) UpdateGameRating(ctx context.Context, id int32) error
- func (s *Storage) UpdateGameTrendingIndex(ctx context.Context, gameID int32, trendingIndex float64) error
- func (s *Storage) UpdateTask(ctx context.Context, task model.Task) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTransactionLocked - error representing transaction lock ErrTransactionLocked = errors.New("transaction locked") )
Functions ¶
func TxFromContext ¶
TxFromContext retrieves transaction from context
Types ¶
type Querier ¶
type Querier interface {
Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
QueryRow(ctx context.Context, sql string, args ...any) pgx.Row
}
Querier defines the interface for executing queries. It's implemented by *pgxpool.Pool and pgx.Tx.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage provides required dependencies for repository
func (*Storage) CreateCompany ¶
CreateCompany creates new company
func (*Storage) CreateGame ¶
CreateGame creates new game
func (*Storage) CreateGenre ¶
CreateGenre creates new genre
func (*Storage) CreateModerationRecord ¶
func (s *Storage) CreateModerationRecord(ctx context.Context, m model.CreateModeration) (id int32, err error)
CreateModerationRecord creates a moderation record for a game
func (*Storage) DeleteGame ¶
DeleteGame deletes game by id. If game does not exist returns apperr.Error with NotFound status code
func (*Storage) GetCompanies ¶
GetCompanies returns companies
func (*Storage) GetCompanyByID ¶
GetCompanyByID returns company by id If company does not exist returns apperr.Error with NotFound status code
func (*Storage) GetCompanyIDByName ¶
GetCompanyIDByName returns company id by name If company does not exist returns apperr.Error with NotFound status code
func (*Storage) GetGameByID ¶
GetGameByID returns game by id. If game does not exist returns apperr.Error with NotFound status code
func (*Storage) GetGameIDByIGDBID ¶
GetGameIDByIGDBID returns game id by igdb id. If game does not exist returns apperr.Error with NotFound status code
func (*Storage) GetGameTrendingData ¶
func (s *Storage) GetGameTrendingData(ctx context.Context, gameID int32) (model.GameTrendingData, error)
GetGameTrendingData retrieves data needed for trending index calculation
func (*Storage) GetGames ¶
func (s *Storage) GetGames(ctx context.Context, pageSize, page uint32, filter model.GamesFilter) (list []model.Game, err error)
GetGames returns games list filtered and paginated
func (*Storage) GetGamesByPublisherID ¶
func (s *Storage) GetGamesByPublisherID(ctx context.Context, publisherID int32) (list []model.Game, err error)
GetGamesByPublisherID returns games created by a specific publisher company id
func (*Storage) GetGamesCount ¶
func (s *Storage) GetGamesCount(ctx context.Context, filter model.GamesFilter) (count uint64, err error)
GetGamesCount returns games count
func (*Storage) GetGamesIDsAfterID ¶
func (s *Storage) GetGamesIDsAfterID(ctx context.Context, lastID int32, batchSize int) ([]int32, error)
GetGamesIDsAfterID returns games ids after provided id
func (*Storage) GetGenreByID ¶
GetGenreByID returns genre by id If company does not exist returns apperr.Error with NotFound status code
func (*Storage) GetModerationRecordByGameID ¶
func (s *Storage) GetModerationRecordByGameID(ctx context.Context, gameID int32) (m model.Moderation, err error)
GetModerationRecordByGameID returns current moderation record by game id
func (*Storage) GetModerationRecordByID ¶
func (s *Storage) GetModerationRecordByID(ctx context.Context, id int32) (m model.Moderation, err error)
GetModerationRecordByID returns moderation record by id
func (*Storage) GetModerationRecordsByGameID ¶
func (s *Storage) GetModerationRecordsByGameID(ctx context.Context, gameID int32) (list []model.Moderation, err error)
GetModerationRecordsByGameID returns moderation records for a game ordered by newest first
func (*Storage) GetPendingModerationGameIDs ¶
func (s *Storage) GetPendingModerationGameIDs(ctx context.Context, limit int) ([]model.ModerationIDGameID, error)
GetPendingModerationGameIDs returns game IDs that have pending moderation status
func (*Storage) GetPlatformByID ¶
func (s *Storage) GetPlatformByID(ctx context.Context, id int32) (platform model.Platform, err error)
GetPlatformByID returns platform by id If company does not exist returns apperr.Error with NotFound status code
func (*Storage) GetPlatforms ¶
GetPlatforms returns platforms
func (*Storage) GetPublisherGamesCount ¶
func (s *Storage) GetPublisherGamesCount(ctx context.Context, publisherID int32, startDate, endDate time.Time) (count int, err error)
GetPublisherGamesCount returns the number of games created by a publisher in the specified date range
func (*Storage) GetTask ¶
GetTask returns task status If task does not exist returns apperr.Error with NotFound status code
func (*Storage) GetTopDevelopers ¶
func (s *Storage) GetTopDevelopers(ctx context.Context, limit int64) (companies []model.Company, err error)
GetTopDevelopers returns top developers by amount of games
func (*Storage) GetTopGenres ¶
GetTopGenres returns genres
func (*Storage) GetTopPublishers ¶
func (s *Storage) GetTopPublishers(ctx context.Context, limit int64) (companies []model.Company, err error)
GetTopPublishers returns top publishers by amount of games
func (*Storage) GetUserRatings ¶
GetUserRatings returns all user ratings
func (*Storage) GetUserRatingsByGamesIDs ¶
func (s *Storage) GetUserRatingsByGamesIDs(ctx context.Context, userID string, gameIDs []int32) (ratings []model.UserRating, err error)
GetUserRatingsByGamesIDs returns user ratings for specified games
func (*Storage) RemoveRating ¶
RemoveRating removes rating of game
func (*Storage) SetModerationRecordResultByGameID ¶
func (s *Storage) SetModerationRecordResultByGameID(ctx context.Context, gameID int32, result model.UpdateModerationResult) error
SetModerationRecordResultByGameID sets moderation result for moderation record by game id. Increments attempts on setting all statuses except `ready`
func (*Storage) SetModerationRecordsStatus ¶
func (s *Storage) SetModerationRecordsStatus(ctx context.Context, ids []int32, status model.ModerationStatus) error
SetModerationRecordsStatus sets moderation status. Increments attempts only on setting `pending` status
func (*Storage) UpdateGame ¶
UpdateGame updates game If game does not exist returns apperr.Error with NotFound status code
func (*Storage) UpdateGameIGDBInfo ¶
func (s *Storage) UpdateGameIGDBInfo(ctx context.Context, id int32, ug model.UpdateGameIGDBData) error
UpdateGameIGDBInfo updates game igdb info If game does not exist returns apperr.Error with NotFound status code
func (*Storage) UpdateGameModerationID ¶
UpdateGameModerationID updates game moderation id
func (*Storage) UpdateGameRating ¶
UpdateGameRating updates game rating If game does not exist returns apperr.Error with NotFound status code