store

package
v0.0.79 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

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

APIClient implements Store by calling the PUMP JSON API. It adds an optional API key on every request via the X-Api-Key header.

func NewAPIClient

func NewAPIClient(baseURL, apiKey string) *APIClient

NewAPIClient constructs a client pointed at baseURL (e.g. "http://localhost:8851"). apiKey may be empty when the API server runs without key protection.

func (*APIClient) BulkReplaceSetsByDate

func (a *APIClient) BulkReplaceSetsByDate(date string, sets []models.Set) error

func (*APIClient) DeleteEx

func (a *APIClient) DeleteEx(id int) error

func (*APIClient) DeleteSet added in v0.0.72

func (a *APIClient) DeleteSet(id int) error

func (*APIClient) DeleteW

func (a *APIClient) DeleteW(id int) error

func (*APIClient) GetConfig

func (a *APIClient) GetConfig() (models.Conf, error)

GetConfig fetches the current configuration from the API.

func (*APIClient) GetSet added in v0.0.72

func (a *APIClient) GetSet(id int) (models.Set, error)

func (*APIClient) InsertEx

func (a *APIClient) InsertEx(ex models.Exercise) error

func (*APIClient) InsertSet added in v0.0.72

func (a *APIClient) InsertSet(set models.Set) (int, error)

func (*APIClient) InsertW

func (a *APIClient) InsertW(w models.BodyWeight) error

func (*APIClient) SaveConfig

func (a *APIClient) SaveConfig(cfg models.Conf) error

SaveConfig persists non-auth configuration fields via the API.

func (*APIClient) SelectEx

func (a *APIClient) SelectEx() ([]models.Exercise, error)

func (*APIClient) SelectSet

func (a *APIClient) SelectSet() ([]models.Set, error)

func (*APIClient) SelectW

func (a *APIClient) SelectW() ([]models.BodyWeight, error)

func (*APIClient) UpdateExColor

func (a *APIClient) UpdateExColor(id int, color string) error

func (*APIClient) UpdateSet added in v0.0.72

func (a *APIClient) UpdateSet(id int, upd models.SetUpdate) error

type PostgresStore

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

PostgresStore implements Store using a PostgreSQL connection pool.

func NewPostgres

func NewPostgres(dsn string) (*PostgresStore, error)

NewPostgres dials the PostgreSQL DSN, pings the server, and returns a ready-to-use store. Call db.MigratePostgres before using the store.

func (*PostgresStore) BulkReplaceSetsByDate

func (s *PostgresStore) BulkReplaceSetsByDate(date string, sets []models.Set) error

func (*PostgresStore) DeleteEx

func (s *PostgresStore) DeleteEx(id int) error

func (*PostgresStore) DeleteSet added in v0.0.72

func (s *PostgresStore) DeleteSet(id int) error

func (*PostgresStore) DeleteW

func (s *PostgresStore) DeleteW(id int) error

func (*PostgresStore) GetSet added in v0.0.72

func (s *PostgresStore) GetSet(id int) (models.Set, error)

func (*PostgresStore) InsertEx

func (s *PostgresStore) InsertEx(ex models.Exercise) error

func (*PostgresStore) InsertSet added in v0.0.72

func (s *PostgresStore) InsertSet(set models.Set) (int, error)

func (*PostgresStore) InsertW

func (s *PostgresStore) InsertW(w models.BodyWeight) error

func (*PostgresStore) Pool

func (s *PostgresStore) Pool() *pgxpool.Pool

Pool exposes the underlying connection pool (used by the migrate package).

func (*PostgresStore) SelectEx

func (s *PostgresStore) SelectEx() ([]models.Exercise, error)

func (*PostgresStore) SelectSet

func (s *PostgresStore) SelectSet() ([]models.Set, error)

func (*PostgresStore) SelectW

func (s *PostgresStore) SelectW() ([]models.BodyWeight, error)

func (*PostgresStore) UpdateExColor

func (s *PostgresStore) UpdateExColor(id int, color string) error

func (*PostgresStore) UpdateSet added in v0.0.72

func (s *PostgresStore) UpdateSet(id int, upd models.SetUpdate) error

type Store

type Store interface {
	SelectEx() ([]models.Exercise, error)
	InsertEx(ex models.Exercise) error
	DeleteEx(id int) error
	UpdateExColor(id int, color string) error

	SelectSet() ([]models.Set, error)
	// BulkReplaceSetsByDate atomically replaces all sets for a given date.
	// Used by the manual-entry form path. Per-set ops below are used by the
	// CV auto-log path and any UI that edits one set at a time.
	BulkReplaceSetsByDate(date string, sets []models.Set) error

	GetSet(id int) (models.Set, error)
	// InsertSet appends a single set and returns its new ID. Empty Source is
	// stored as "manual"; zero Confidence is stored as 1.0; Pending defaults
	// to false. Other defaults come from the schema.
	InsertSet(set models.Set) (int, error)
	UpdateSet(id int, upd models.SetUpdate) error
	DeleteSet(id int) error

	SelectW() ([]models.BodyWeight, error)
	InsertW(w models.BodyWeight) error
	DeleteW(id int) error
}

Store abstracts data access so both the monolith (SQLite) and the split frontend (HTTP API client) can satisfy the same interface.

Jump to

Keyboard shortcuts

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