repository

package
v0.0.0-...-526dcec Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalDeterministic

func MarshalDeterministic(m map[string]interface{}) (string, error)

func NewPostgresDB

func NewPostgresDB(cfg PostgresConfig) (*sqlx.DB, error)

func NewRedisDB

func NewRedisDB(cfg RedisConfig) (*redis.Client, error)

Types

type AdminPostgres

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

func NewAdminPostgres

func NewAdminPostgres(db *sqlx.DB) *AdminPostgres

func (*AdminPostgres) BanLevel

func (s *AdminPostgres) BanLevel(levelId int) error

func (*AdminPostgres) BanUser

func (s *AdminPostgres) BanUser(userId int, expirationTime time.Time, reason string) error

func (*AdminPostgres) ChangeUserAccess

func (s *AdminPostgres) ChangeUserAccess(userId int, newAccess int) error

func (*AdminPostgres) DeleteLevelComplaint

func (s *AdminPostgres) DeleteLevelComplaint(moderatorId int, complaintId int) error

func (*AdminPostgres) DeleteUserComplaint

func (s *AdminPostgres) DeleteUserComplaint(moderatorId int, complaintId int) error

func (*AdminPostgres) GetLevelComplaints

func (s *AdminPostgres) GetLevelComplaints(moderatorId int) ([]complaints.LevelComplaint, error)

func (*AdminPostgres) GetUserAccess

func (s *AdminPostgres) GetUserAccess(id int) (int, error)

func (*AdminPostgres) GetUserComplaints

func (s *AdminPostgres) GetUserComplaints(moderatorId int) ([]complaints.UserComplaint, error)

func (*AdminPostgres) GetUsers

func (s *AdminPostgres) GetUsers(params user.UserSearchParams) ([]user.UserInfo, error)

func (*AdminPostgres) UnbanLevel

func (s *AdminPostgres) UnbanLevel(levelId int) error

func (*AdminPostgres) UnbanUser

func (s *AdminPostgres) UnbanUser(userId int) error

type AuthPostgres

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

func NewAuthPostgres

func NewAuthPostgres(db *sqlx.DB) *AuthPostgres

func (*AuthPostgres) CreateSeniorAdmin

func (s *AuthPostgres) CreateSeniorAdmin(name string, password string) error

func (*AuthPostgres) CreateStats

func (s *AuthPostgres) CreateStats(tx *sql.Tx, userId int) error

func (*AuthPostgres) CreateUser

func (s *AuthPostgres) CreateUser(user user.User) (int, int, string, error)

func (*AuthPostgres) GetUser

func (s *AuthPostgres) GetUser(username, password string) (user.User, error)

func (*AuthPostgres) GetUserById

func (s *AuthPostgres) GetUserById(id int) (user.User, error)

func (*AuthPostgres) SetUserRefreshToken

func (s *AuthPostgres) SetUserRefreshToken(id int, refreshToken string, expiresAt time.Time) (int, int, string, error)

type LevelPostgres

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

TODO: Finish sorting

func NewLevelPostgres

func NewLevelPostgres(db *sqlx.DB, client *redis.Client, levelUserTopTTL, levelStatsTTL int) *LevelPostgres

func NewLevelPostgresMock

func NewLevelPostgresMock(db *sqlx.DB, client *redis.Client) *LevelPostgres

func (*LevelPostgres) CreateLevel

func (lp *LevelPostgres) CreateLevel(level levels.Level) (string, string, int, error)

func (*LevelPostgres) DeleteLevel

func (lp *LevelPostgres) DeleteLevel(levelId int) error

func (*LevelPostgres) FetchLevels

func (lp *LevelPostgres) FetchLevels(params map[string]interface{}) ([]levels.Level, error)

func (*LevelPostgres) GetLevelById

func (lp *LevelPostgres) GetLevelById(levelId int) (levels.Level, error)

func (*LevelPostgres) GetLevelStats

func (lp *LevelPostgres) GetLevelStats(levelId int) (statistics.LevelStats, error)

func (*LevelPostgres) GetLevelStatsFromCache

func (sp *LevelPostgres) GetLevelStatsFromCache(levelId int) (statistics.LevelStats, error)

func (*LevelPostgres) GetLevelUserTop

func (lp *LevelPostgres) GetLevelUserTop(levelId int) ([]statistics.UserLevelCompletionInfo, error)

func (*LevelPostgres) GetLevelUserTopFromCache

func (sp *LevelPostgres) GetLevelUserTopFromCache(levelId int) ([]statistics.UserLevelCompletionInfo, error)

func (*LevelPostgres) GetPathsById

func (lp *LevelPostgres) GetPathsById(levelId int) (int, string, string, error)

func (*LevelPostgres) GetTagsByLevelID

func (lp *LevelPostgres) GetTagsByLevelID(levelID int) ([]levels.Tag, error)

func (*LevelPostgres) InsertTags

func (lp *LevelPostgres) InsertTags(tx *sqlx.Tx, levelID int, tags []string) error

func (*LevelPostgres) SaveLevelStatsInCache

func (sp *LevelPostgres) SaveLevelStatsInCache(levelId int, result statistics.LevelStats) error

func (*LevelPostgres) SaveLevelUserTopInCache

func (sp *LevelPostgres) SaveLevelUserTopInCache(levelId int, result []statistics.UserLevelCompletionInfo) error

func (*LevelPostgres) UpdateLevel

func (lp *LevelPostgres) UpdateLevel(levelInfo levels.LevelUpdateStruct) (string, string, int, error)

type LocalFileRepository

type LocalFileRepository struct{}

func NewLocalFileRepository

func NewLocalFileRepository() *LocalFileRepository

func (*LocalFileRepository) DeleteFile

func (r *LocalFileRepository) DeleteFile(path string) error

func (*LocalFileRepository) SaveFile

func (r *LocalFileRepository) SaveFile(file *multipart.FileHeader, filePath string) error

type PostgresConfig

type PostgresConfig struct {
	Host     string
	Port     string
	Username string
	Password string
	DBName   string
	SSLMode  string
}

type RedisConfig

type RedisConfig struct {
	Host         string
	Port         string
	Password     string
	Maxmemory    string
	MaxMemPolicy string
}

type Repository

type Repository struct {
	Authorization    repository.Authorization
	UserActions      repository.UserActions
	AdminActions     repository.Admin
	Level            repository.Level
	Stats            repository.Stats
	SinglePlayerGame repository.SinglePlayerGame
	Files            repository.Files
}

func NewRepository

func NewRepository(db *sqlx.DB, client *redis.Client, levelUserTopTTL, levelStatsTTL, ratingTTL int) *Repository

type SinglePlayerGamePostgres

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

func NewSinglePlayerGamePostgres

func NewSinglePlayerGamePostgres(db *sqlx.DB) *SinglePlayerGamePostgres

func (*SinglePlayerGamePostgres) SendResults

func (s *SinglePlayerGamePostgres) SendResults(lc statistics.LevelComplete, totalPush int, totalErr int) error

type StatsPostgres

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

func NewStatsPostgres

func NewStatsPostgres(db *sqlx.DB, client *redis.Client, ratingTtl int) *StatsPostgres

func NewStatsPostgresMock

func NewStatsPostgresMock(db *sqlx.DB, client *redis.Client) *StatsPostgres

func (*StatsPostgres) GetUserStats

func (sp *StatsPostgres) GetUserStats(id int) (statistics.PlayerStats, error)

func (*StatsPostgres) GetUserTopFromCache

func (sp *StatsPostgres) GetUserTopFromCache(params map[string]interface{}) ([]statistics.PlayerStats, error)

func (*StatsPostgres) GetUsersTop

func (sp *StatsPostgres) GetUsersTop(params map[string]interface{}) ([]statistics.PlayerStats, error)

func (*StatsPostgres) SaveUserTopInCache

func (sp *StatsPostgres) SaveUserTopInCache(params map[string]interface{}, result []statistics.PlayerStats) error

type UserActionsPostgres

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

func NewUserActionsPostgres

func NewUserActionsPostgres(db *sqlx.DB) *UserActionsPostgres

func (*UserActionsPostgres) CreateLevelComplaint

func (s *UserActionsPostgres) CreateLevelComplaint(complaint complaints.LevelComplaint) error

func (*UserActionsPostgres) CreateUserComplaint

func (s *UserActionsPostgres) CreateUserComplaint(complaint complaints.UserComplaint) error

func (*UserActionsPostgres) DropRefreshToken

func (s *UserActionsPostgres) DropRefreshToken(id int, newTime time.Time) (int, error)

func (*UserActionsPostgres) GetUserById

func (s *UserActionsPostgres) GetUserById(id int) (string, int, time.Time, string, sql.NullString, error)

func (*UserActionsPostgres) UpdateAvatarPath

func (s *UserActionsPostgres) UpdateAvatarPath(id int, newPath string) (string, error)

Jump to

Keyboard shortcuts

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