storage

package
v0.0.0-...-fda8326 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DATA_FORMAT_VERSION = 1
View Source
const DB_NAME = "flashlight"
View Source
const LOCAL_CONNECTION_STRING = "user=postgres password=postgres dbname=flashlight sslmode=disable"
View Source
const MAIN_SCHEMA = "flashlight"
View Source
const TESTING_SCHEMA = "flashlight_test"

Variables

This section is empty.

Functions

func GetCloudSQLConnectionString

func GetCloudSQLConnectionString(dbUsername, dbPassword, unixSocketPath string) string

https://cloud.google.com/sql/docs/mysql/connect-functions

func GetSchemaName

func GetSchemaName(isTesting bool) string

func NewDatabaseMigrator

func NewDatabaseMigrator(db *sqlx.DB, logger *slog.Logger) *migrator

func NewPostgresDatabase

func NewPostgresDatabase(connectionString string) (*sqlx.DB, error)

Types

type PlayerDataPIT

type PlayerDataPIT struct {
	ID                string
	DataFormatVersion int
	UUID              string
	QueriedAt         time.Time
	Experience        *float64
	Solo              StatsPIT
	Doubles           StatsPIT
	Threes            StatsPIT
	Fours             StatsPIT
	Overall           StatsPIT
}

type PostgresStatsPersistor

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

func NewPostgresStatsPersistor

func NewPostgresStatsPersistor(db *sqlx.DB, schema string) *PostgresStatsPersistor

func (*PostgresStatsPersistor) GetHistory

func (p *PostgresStatsPersistor) GetHistory(ctx context.Context, playerUUID string, start, end time.Time, limit int) ([]PlayerDataPIT, error)

func (*PostgresStatsPersistor) StoreStats

func (p *PostgresStatsPersistor) StoreStats(ctx context.Context, playerUUID string, player *processing.HypixelAPIPlayer, queriedAt time.Time) error

type StatsPIT

type StatsPIT struct {
	Winstreak   *int
	GamesPlayed *int
	Wins        *int
	Losses      *int
	BedsBroken  *int
	BedsLost    *int
	FinalKills  *int
	FinalDeaths *int
	Kills       *int
	Deaths      *int
}

type StatsPersistor

type StatsPersistor interface {
	StoreStats(ctx context.Context, playerUUID string, player *processing.HypixelAPIPlayer, queriedAt time.Time) error
	GetHistory(ctx context.Context, playerUUID string, start, end time.Time, limit int) ([]PlayerDataPIT, error)
}

func NewPostgresStatsPersistorOrMock

func NewPostgresStatsPersistorOrMock(conf config.Config, logger *slog.Logger) (StatsPersistor, error)

type StubPersistor

type StubPersistor struct{}

func NewStubPersistor

func NewStubPersistor() *StubPersistor

func (*StubPersistor) GetHistory

func (p *StubPersistor) GetHistory(ctx context.Context, playerUUID string, start, end time.Time, limit int) ([]PlayerDataPIT, error)

func (*StubPersistor) StoreStats

func (p *StubPersistor) StoreStats(ctx context.Context, playerUUID string, player *processing.HypixelAPIPlayer, queriedAt time.Time) error

Jump to

Keyboard shortcuts

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