Documentation
¶
Index ¶
- Constants
- type IGDBAPIClient
- type OpenAIClient
- type Provider
- func (p *Provider) CompanyExistsInIGDB(ctx context.Context, companyName string) (bool, error)
- func (p *Provider) CreateCompany(ctx context.Context, company model.Company) (int32, error)
- func (p *Provider) CreateGame(ctx context.Context, cg model.CreateGame) (id int32, err error)
- func (p *Provider) CreateModerationRecord(ctx context.Context, gameID int32) (int32, error)
- func (p *Provider) DeleteGame(ctx context.Context, id int32, publisher string) error
- func (p *Provider) GetCompanies(ctx context.Context) ([]model.Company, error)
- func (p *Provider) GetCompaniesMap(ctx context.Context) (map[int32]model.Company, error)
- func (p *Provider) GetCompanyByID(ctx context.Context, id int32) (model.Company, error)
- func (p *Provider) GetGameByID(ctx context.Context, id int32) (model.Game, error)
- func (p *Provider) GetGameModerations(ctx context.Context, gameID int32, publisher string) ([]model.Moderation, error)
- func (p *Provider) GetGames(ctx context.Context, page, pageSize uint32, filter model.GamesFilter) (games []model.Game, count uint64, err error)
- func (p *Provider) GetGenreByID(ctx context.Context, id int32) (model.Genre, error)
- func (p *Provider) GetGenres(ctx context.Context) ([]model.Genre, error)
- func (p *Provider) GetGenresMap(ctx context.Context) (map[int32]model.Genre, error)
- func (p *Provider) GetPlatformByID(ctx context.Context, id int32) (model.Platform, error)
- func (p *Provider) GetPlatforms(ctx context.Context) ([]model.Platform, error)
- func (p *Provider) GetPlatformsMap(ctx context.Context) (map[int32]model.Platform, error)
- func (p *Provider) GetPublisherGames(ctx context.Context, publisher string) ([]model.Game, error)
- func (p *Provider) GetTopCompanies(ctx context.Context, companyType string, limit int64) ([]model.Company, error)
- func (p *Provider) GetTopGenres(ctx context.Context, limit int64) ([]model.Genre, error)
- func (p *Provider) GetUserRatings(ctx context.Context, userID string) (map[int32]uint8, error)
- func (p *Provider) ProcessModeration(ctx context.Context, gameID int32) error
- func (p *Provider) RateGame(ctx context.Context, gameID int32, userID string, rating uint8) error
- func (p *Provider) UpdateGame(ctx context.Context, id int32, upd model.UpdateGame) error
- func (p *Provider) UpdateGameTrendingIndex(ctx context.Context, gameID int32) error
- func (p *Provider) UploadGameImages(ctx context.Context, coverFiles, screenshotFiles []*multipart.FileHeader, ...) ([]model.File, error)
- type S3Client
- type Storage
Constants ¶
const ( // ImageTypeCover type for cover image ImageTypeCover = "cover" // ImageTypeScreenshot type for screenshot images ImageTypeScreenshot = "screenshot" // MaxImageSizeKB maximum upload image size in KB MaxImageSizeKB int64 = 1024 // MaxCovers maximum number of cover files allowed MaxCovers = 1 // MaxScreenshots maximum number of screenshot files allowed MaxScreenshots = 8 )
const (
// MaxGamesPerPublisherPerMonth is the maximum number of games a publisher can create in a month
MaxGamesPerPublisherPerMonth = 2
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IGDBAPIClient ¶
type IGDBAPIClient interface {
CompanyExists(ctx context.Context, companyName string) (bool, error)
}
IGDBAPIClient defines methods for interacting with IGDB API
type OpenAIClient ¶
type OpenAIClient interface {
ModerateText(ctx context.Context, gameData model.ModerationData) (*openaiapi.ModerationResponse, error)
AnalyzeGameImages(ctx context.Context, gameData model.ModerationData) (*openaiapi.VisionAnalysisResult, error)
}
OpenAIClient represents the interface for OpenAI client operations
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider represents dependencies for facade layer
func NewProvider ¶
func NewProvider(logger *zap.Logger, storage Storage, cache *cache.RedisStore, s3Client S3Client, openAIClient OpenAIClient, igdbAPIClient IGDBAPIClient) *Provider
NewProvider returns new facade provider
func (*Provider) CompanyExistsInIGDB ¶
CompanyExistsInIGDB check if company name exists in igdb
func (*Provider) CreateCompany ¶
CreateCompany creates a new company
func (*Provider) CreateGame ¶
CreateGame creates new game
func (*Provider) CreateModerationRecord ¶
CreateModerationRecord creates a moderation record for a game
func (*Provider) DeleteGame ¶
DeleteGame deletes game by id
func (*Provider) GetCompanies ¶
GetCompanies returns companies
func (*Provider) GetCompaniesMap ¶
GetCompaniesMap returns all companies map
func (*Provider) GetCompanyByID ¶
GetCompanyByID returns company by id
func (*Provider) GetGameByID ¶
GetGameByID returns game by id
func (*Provider) GetGameModerations ¶
func (p *Provider) GetGameModerations(ctx context.Context, gameID int32, publisher string) ([]model.Moderation, error)
GetGameModerations returns all moderations for a game, ensuring the caller is its publisher
func (*Provider) GetGames ¶
func (p *Provider) GetGames(ctx context.Context, page, pageSize uint32, filter model.GamesFilter) (games []model.Game, count uint64, err error)
GetGames returns games and count with pagination
func (*Provider) GetGenreByID ¶
GetGenreByID returns genre by id
func (*Provider) GetGenresMap ¶
GetGenresMap returns all genres map
func (*Provider) GetPlatformByID ¶
GetPlatformByID returns platform by id
func (*Provider) GetPlatforms ¶
GetPlatforms returns all platforms
func (*Provider) GetPlatformsMap ¶
GetPlatformsMap returns all platforms map
func (*Provider) GetPublisherGames ¶
GetPublisherGames returns games created by the publisher
func (*Provider) GetTopCompanies ¶
func (p *Provider) GetTopCompanies(ctx context.Context, companyType string, limit int64) ([]model.Company, error)
GetTopCompanies returns top companies by type
func (*Provider) GetTopGenres ¶
GetTopGenres returns top genres
func (*Provider) GetUserRatings ¶
GetUserRatings returns user's rating for specified games
func (*Provider) ProcessModeration ¶
ProcessModeration processes moderation for a game using a two-phase approach: 1. Basic moderation: Uses OpenAI moderation API to check for policy violations in text and images 2. Gaming-specific analysis: Uses vision model to analyze images for gaming appropriateness and relevance
func (*Provider) UpdateGame ¶
UpdateGame updates game
func (*Provider) UpdateGameTrendingIndex ¶
UpdateGameTrendingIndex updates the trending index for a game
type S3Client ¶
type S3Client interface {
Upload(ctx context.Context, data io.ReadSeeker, contentType string, md map[string]string) (s3.UploadResult, error)
}
S3Client represents the interface for S3 client operations
type Storage ¶
type Storage interface {
GetGames(ctx context.Context, pageSize, page uint32, filter model.GamesFilter) (list []model.Game, err error)
GetGamesCount(ctx context.Context, filter model.GamesFilter) (count uint64, err error)
GetGameByID(ctx context.Context, id int32) (game model.Game, err error)
CreateGame(ctx context.Context, cg model.CreateGameData) (id int32, err error)
UpdateGame(ctx context.Context, id int32, ug model.UpdateGameData) error
DeleteGame(ctx context.Context, id int32) error
UpdateGameRating(ctx context.Context, id int32) error
GetPublisherGamesCount(ctx context.Context, publisherID int32, startDate, endDate time.Time) (count int, err error)
UpdateGameTrendingIndex(ctx context.Context, gameID int32, trendingIndex float64) error
UpdateGameModerationID(ctx context.Context, gameID, moderationID int32) error
GetGameTrendingData(ctx context.Context, gameID int32) (model.GameTrendingData, error)
GetGamesByPublisherID(ctx context.Context, publisherID int32) (list []model.Game, err error)
CreateCompany(ctx context.Context, c model.Company) (id int32, err error)
GetCompanies(ctx context.Context) (companies []model.Company, err error)
GetCompanyByID(ctx context.Context, id int32) (company model.Company, err error)
GetCompanyIDByName(ctx context.Context, name string) (id int32, err error)
GetTopDevelopers(ctx context.Context, limit int64) (companies []model.Company, err error)
GetTopPublishers(ctx context.Context, limit int64) (companies []model.Company, err error)
GetGenres(ctx context.Context) (genres []model.Genre, err error)
GetGenreByID(ctx context.Context, id int32) (genre model.Genre, err error)
GetTopGenres(ctx context.Context, limit int64) (genres []model.Genre, err error)
GetPlatforms(ctx context.Context) (platforms []model.Platform, err error)
GetPlatformByID(ctx context.Context, id int32) (platform model.Platform, err error)
AddRating(ctx context.Context, cr model.CreateRating) error
RemoveRating(ctx context.Context, rr model.RemoveRating) error
GetUserRatings(ctx context.Context, userID string) (map[int32]uint8, error)
GetModerationRecordsByGameID(ctx context.Context, gameID int32) (list []model.Moderation, err error)
CreateModerationRecord(ctx context.Context, m model.CreateModeration) (id int32, err error)
SetModerationRecordResultByGameID(ctx context.Context, gameID int32, res model.UpdateModerationResult) error
SetModerationRecordsStatus(ctx context.Context, gameIDs []int32, status model.ModerationStatus) error
GetModerationRecordByID(ctx context.Context, id int32) (m model.Moderation, err error)
GetModerationRecordByGameID(ctx context.Context, gameID int32) (m model.Moderation, err error)
RunWithTx(ctx context.Context, f func(context.Context) error) error
}
Storage provides methods for working with database