repository

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPageSize = 50

Variables

This section is empty.

Functions

This section is empty.

Types

type CursorParams

type CursorParams struct {
	Limit  int
	Cursor *time.Time
}

type CursorResult

type CursorResult[T any] struct {
	Records    []T
	NextCursor *time.Time
}

type CycleRepository

type CycleRepository interface {
	Upsert(ctx context.Context, cycle *whoop.Cycle) error
	UpsertBatch(ctx context.Context, cycles []whoop.Cycle) error
	Get(ctx context.Context, id int64) (*whoop.Cycle, error)
	GetByDate(ctx context.Context, date time.Time) (*whoop.Cycle, error)
	GetLatest(ctx context.Context, limit int) ([]whoop.Cycle, error)
	GetByDateRange(ctx context.Context, start, end time.Time, cursor *CursorParams) (*CursorResult[whoop.Cycle], error)
	GetPending(ctx context.Context) ([]whoop.Cycle, error)
}

type RecoveryRepository

type RecoveryRepository interface {
	Upsert(ctx context.Context, recovery *whoop.Recovery) error
	UpsertBatch(ctx context.Context, recoveries []whoop.Recovery) error
	Get(ctx context.Context, cycleID int64) (*whoop.Recovery, error)
	GetByCycleIDs(ctx context.Context, cycleIDs []int64) ([]whoop.Recovery, error)
	Delete(ctx context.Context, cycleID int64) error
}

type Repository

type Repository struct {
	SyncState  SyncStateRepository
	Cycles     CycleRepository
	Recoveries RecoveryRepository
	Sleeps     SleepRepository
	Workouts   WorkoutRepository
}

func New

func New(q sqlitec.Querier) *Repository

type SleepRepository

type SleepRepository interface {
	Upsert(ctx context.Context, sleep *whoop.Sleep) error
	UpsertBatch(ctx context.Context, sleeps []whoop.Sleep) error
	Get(ctx context.Context, id string) (*whoop.Sleep, error)
	GetByCycleID(ctx context.Context, cycleID int64) (*whoop.Sleep, error)
	GetByDateRange(ctx context.Context, start, end time.Time, cursor *CursorParams) (*CursorResult[whoop.Sleep], error)
	Delete(ctx context.Context, id string) error
}

type SyncState

type SyncState struct {
	BackfillComplete     bool
	BackfillWatermark    *time.Time
	LastFullSync         *time.Time
	LastNotificationPoll *time.Time
}

type SyncStateRepository

type SyncStateRepository interface {
	Get(ctx context.Context) (*SyncState, error)
	Upsert(ctx context.Context, state *SyncState) error
	MarkBackfillComplete(ctx context.Context) error
	UpdateBackfillWatermark(ctx context.Context, watermark time.Time) error
	UpdateLastFullSync(ctx context.Context, syncTime time.Time) error
	GetLastNotificationPoll(ctx context.Context) (*time.Time, error)
	UpdateLastNotificationPoll(ctx context.Context, pollTime time.Time) error
}

type WorkoutRepository

type WorkoutRepository interface {
	Upsert(ctx context.Context, workout *whoop.Workout) error
	UpsertBatch(ctx context.Context, workouts []whoop.Workout) error
	Get(ctx context.Context, id string) (*whoop.Workout, error)
	GetByDateRange(ctx context.Context, start, end time.Time, cursor *CursorParams) (*CursorResult[whoop.Workout], error)
	Delete(ctx context.Context, id string) error
}

Jump to

Keyboard shortcuts

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