service

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Guess

type Guess interface {
	CountFromDate(ctx context.Context, from time.Time) (int, error)

	FindLatest(ctx context.Context) ([]domain.Guess, error)
	FindByUser(ctx context.Context, userId, limit, page int) (domain.PagedResult[domain.Guess], error)
	FindById(ctx context.Context, id string) (domain.Guess, error)
	FindTopFromDate(ctx context.Context, from time.Time, limit int) ([]domain.GuessExtended, error)

	CreateAndUpdateUserElo(ctx context.Context, userId int, input domain.GuessCreate) (int, domain.Guess, error)
}

func NewGuess

func NewGuess(guesses repo.Guesses, users repo.Users, uow *uow.UnitOfWork) Guess

type Players

type Players interface {
	FindRandom(ctx context.Context) (domain.Player, error)
	Find(ctx context.Context, limit, page int) ([]domain.Player, error)
	CreateMany(ctx context.Context, ids []domain.PlayerCreate) (int64, error)
}

func NewPlayer

func NewPlayer(repo repo.Players) Players

type Rooms

type Rooms interface {
	FindByUserUnguessed(ctx context.Context, userId int) (domain.Room, error)
	FindRandomScore(ctx context.Context, accessToken string) (osuapi.Score, error)
	FindByUser(ctx context.Context, userId int, accessToken string) (domain.RoomExtended, error)
	FindOrDeleteExpired(ctx context.Context, id, accessToken string, userId int) (domain.RoomExtended, error)

	UpdateGuessID(ctx context.Context, id string, guessId string) error
	SetNext(ctx context.Context, id string, userId, playerId, scoreId int) (refill domain.RefillResult, room domain.Room, err error)
	Create(ctx context.Context, playerId, userId, scoreId int, kind domain.RoomKind) (domain.RefillResult, domain.Room, error)

	DeleteById(ctx context.Context, id string) error
	DeleteByUser(ctx context.Context, userId int) error
	DeleteByUserUnguessed(ctx context.Context, userId int) error

	RefillForUser(ctx context.Context, userId int, sub uint) (domain.RefillResult, error)

	// works for now, but should be moved to a separate service
	GetScore(ctx context.Context, accessToken string, scoreId int) (osuapi.Score, error)
}

func NewRooms

func NewRooms(
	repo repo.Rooms, users repo.Users, players repo.Players, guessesSvc Guess,
	oapi *osuapi.Client, rdb *redis.Client, uow *uow.UnitOfWork,
) Rooms

type Sessions

type Sessions interface {
	Find(ctx context.Context, id string) (domain.Session, error)
	FindWithUser(ctx context.Context, id string) (domain.SessionExtended, error)

	DeleteByUser(ctx context.Context, osuId int) error
	UpdateTokens(ctx context.Context, id, accessToken, refreshToken string, expiresAt time.Time) error
	Create(ctx context.Context, osuId int, accessToken, refreshToken string, expiresAt time.Time) (domain.Session, error)
}

func NewSessions

func NewSessions(cfg *config.Config, repo repo.Sessions) Sessions

type Submissions

type Submissions interface {
	Create(ctx context.Context, input domain.SubmissionCreate) (domain.Submission, error)
	Delete(ctx context.Context, id string) error
	SetAccepted(ctx context.Context, id string) error

	FindRandom(ctx context.Context, userId int) (domain.Submission, error)
	FindRandomWithScore(ctx context.Context, userId int, accessToken string) (osuapi.Score, error)
	FindByUser(ctx context.Context, userId int, accepted bool) ([]domain.Submission, error)
	Find(ctx context.Context, accepted bool, limit, page int) ([]domain.SubmissionExtended, error)
}

func NewSubmissions

func NewSubmissions(repo repo.Submissions, client *osuapi.Client) Submissions

type User

type User interface {
	Upsert(ctx context.Context, osuId int, username, avatarURL, countryCode string) error

	FindTop(ctx context.Context, limit, page int) ([]domain.UserExtended, error)
	FindByOsuID(ctx context.Context, osuId int) (domain.User, error)
}

func NewUser

func NewUser(repo repo.Users) User

Jump to

Keyboard shortcuts

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