runstore

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Config added in v0.5.0

func Config() *pgxpool.Config

func GetDistanceKm

func GetDistanceKm(d float64) string

Types

type CreateRunParams added in v0.5.0

type CreateRunParams struct {
	Date     time.Time `json:"date"`
	Distance float64   `json:"distance"`
	Runtime  int32     `json:"runtime"`
}

type DBTX added in v0.5.0

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type InMemoryRunnerStore

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

func (*InMemoryRunnerStore) GetRunnerRuns

func (i *InMemoryRunnerStore) GetRunnerRuns() []Run

func (*InMemoryRunnerStore) GetRunnerStravaToken added in v0.5.0

func (i *InMemoryRunnerStore) GetRunnerStravaToken(userid uuid.UUID) (StravaToken, error)

func (*InMemoryRunnerStore) RecordRun

func (i *InMemoryRunnerStore) RecordRun(r Run)

type PlanRun

type PlanRun struct {
	Date     time.Time
	Distance float32 //All distances stored in m.
}

func (PlanRun) GetRunDateString

func (r PlanRun) GetRunDateString() string

func (PlanRun) GetRunDistanceKm

func (r PlanRun) GetRunDistanceKm() string

type Queries added in v0.5.0

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

func New added in v0.5.0

func New(db DBTX) *Queries

func (*Queries) CreateRun added in v0.5.0

func (q *Queries) CreateRun(ctx context.Context, arg CreateRunParams) (Run, error)

func (*Queries) GetRuns added in v0.5.0

func (q *Queries) GetRuns(ctx context.Context) ([]Run, error)

func (*Queries) GetSchemaVersion added in v0.5.0

func (q *Queries) GetSchemaVersion(ctx context.Context) (SchemaMigration, error)

func (*Queries) GetStravaToken added in v0.5.0

func (q *Queries) GetStravaToken(ctx context.Context, id uuid.UUID) (StravaToken, error)

func (*Queries) WithTx added in v0.5.0

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type Run

type Run struct {
	Date     time.Time `json:"date"`
	Distance float64   `json:"distance"`
	Runtime  int32     `json:"runtime"`
}

func (Run) GetRunDateString

func (r Run) GetRunDateString() string

func (Run) GetRunDistanceKm

func (r Run) GetRunDistanceKm() string

func (Run) GetRunPace

func (r Run) GetRunPace() string

func (Run) GetRuntime added in v0.5.0

func (r Run) GetRuntime() int

func (Run) GetRuntimeString added in v0.5.0

func (r Run) GetRuntimeString() string

type SQLRunnerStore

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

func NewSQLRunerStore

func NewSQLRunerStore(ctx context.Context) (*SQLRunnerStore, error)

func (*SQLRunnerStore) GetRunnerRuns

func (rs *SQLRunnerStore) GetRunnerRuns() []Run

func (*SQLRunnerStore) GetRunnerStravaToken added in v0.5.0

func (rs *SQLRunnerStore) GetRunnerStravaToken(userid uuid.UUID) (StravaToken, error)

func (*SQLRunnerStore) RecordRun

func (rs *SQLRunnerStore) RecordRun(r Run)

type SchemaMigration added in v0.5.0

type SchemaMigration struct {
	Version int32       `json:"version"`
	Dirty   pgtype.Bool `json:"dirty"`
}

type Store

type Store interface {
	GetRunnerStravaToken(uuid.UUID) (StravaToken, error)
	GetRunnerRuns() []Run
	RecordRun(Run)
}

type StravaToken added in v0.5.0

type StravaToken struct {
	ID           uuid.UUID `json:"id"`
	AccessToken  string    `json:"access_token"`
	ExpiresAt    int32     `json:"expires_at"`
	RefreshToken string    `json:"refresh_token"`
}

type User added in v0.5.0

type User struct {
	ID          uuid.UUID   `json:"id"`
	Name        string      `json:"name"`
	Email       string      `json:"email"`
	StravaToken pgtype.UUID `json:"strava_token"`
}

Jump to

Keyboard shortcuts

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