repo

package
v0.0.0-...-efe0c35 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTransactionLocked - error representing transaction lock
	ErrTransactionLocked = errors.New("transaction locked")
)

Functions

func TxFromContext

func TxFromContext(ctx context.Context) (pgx.Tx, bool)

TxFromContext retrieves transaction from context

func WithTx

func WithTx(ctx context.Context, tx pgx.Tx) context.Context

WithTx stores transaction in 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 New

func New(db *pgxpool.Pool, log *zap.Logger) *Storage

New creates new Storage

func (*Storage) AddRating

func (s *Storage) AddRating(ctx context.Context, cr model.CreateRating) error

AddRating adds rating to game

func (*Storage) BeginTx

func (s *Storage) BeginTx(ctx context.Context) (pgx.Tx, error)

BeginTx starts transaction

func (*Storage) CreateCompany

func (s *Storage) CreateCompany(ctx context.Context, c model.Company) (id int32, err error)

CreateCompany creates new company

func (*Storage) CreateGame

func (s *Storage) CreateGame(ctx context.Context, cg model.CreateGameData) (id int32, err error)

CreateGame creates new game

func (*Storage) CreateGenre

func (s *Storage) CreateGenre(ctx context.Context, g model.Genre) (id int32, err error)

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

func (s *Storage) DeleteGame(ctx context.Context, id int32) error

DeleteGame deletes game by id. If game does not exist returns apperr.Error with NotFound status code

func (*Storage) GetCompanies

func (s *Storage) GetCompanies(ctx context.Context) (companies []model.Company, err error)

GetCompanies returns companies

func (*Storage) GetCompanyByID

func (s *Storage) GetCompanyByID(ctx context.Context, id int32) (company model.Company, err error)

GetCompanyByID returns company by id If company does not exist returns apperr.Error with NotFound status code

func (*Storage) GetCompanyIDByName

func (s *Storage) GetCompanyIDByName(ctx context.Context, name string) (id int32, err error)

GetCompanyIDByName returns company id by name If company does not exist returns apperr.Error with NotFound status code

func (*Storage) GetGameByID

func (s *Storage) GetGameByID(ctx context.Context, id int32) (game model.Game, err error)

GetGameByID returns game by id. If game does not exist returns apperr.Error with NotFound status code

func (*Storage) GetGameIDByIGDBID

func (s *Storage) GetGameIDByIGDBID(ctx context.Context, igdbID int64) (id int32, err error)

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

func (s *Storage) GetGenreByID(ctx context.Context, id int32) (genre model.Genre, err error)

GetGenreByID returns genre by id If company does not exist returns apperr.Error with NotFound status code

func (*Storage) GetGenres

func (s *Storage) GetGenres(ctx context.Context) (genres []model.Genre, err error)

GetGenres returns genres

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

func (s *Storage) GetPlatforms(ctx context.Context) (platforms []model.Platform, err error)

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

func (s *Storage) GetTask(ctx context.Context, name string) (task model.Task, err error)

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

func (s *Storage) GetTopGenres(ctx context.Context, limit int64) (genres []model.Genre, err error)

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

func (s *Storage) GetUserRatings(ctx context.Context, userID string) (map[int32]uint8, error)

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

func (s *Storage) RemoveRating(ctx context.Context, rr model.RemoveRating) error

RemoveRating removes rating of game

func (*Storage) RunWithTx

func (s *Storage) RunWithTx(ctx context.Context, f func(context.Context) error) error

RunWithTx runs a function in a transaction

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

func (s *Storage) UpdateGame(ctx context.Context, id int32, ug model.UpdateGameData) error

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

func (s *Storage) UpdateGameModerationID(ctx context.Context, gameID, moderationID int32) error

UpdateGameModerationID updates game moderation id

func (*Storage) UpdateGameRating

func (s *Storage) UpdateGameRating(ctx context.Context, id int32) error

UpdateGameRating updates game rating If game does not exist returns apperr.Error with NotFound status code

func (*Storage) UpdateGameTrendingIndex

func (s *Storage) UpdateGameTrendingIndex(ctx context.Context, gameID int32, trendingIndex float64) error

UpdateGameTrendingIndex updates the trending index for a specific game

func (*Storage) UpdateTask

func (s *Storage) UpdateTask(ctx context.Context, task model.Task) error

UpdateTask updates task

Directories

Path Synopsis
Package repo_mock is a generated GoMock package.
Package repo_mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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