store

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateBPCategory

func CalculateBPCategory(systolic, diastolic int) string

func CalculateWeightTrend

func CalculateWeightTrend(currentWeight float64, previousTrend *float64) float64

CalculateWeightTrend calculates a simple exponential moving average alpha = 0.1 gives roughly a 20-day smoothing

func CategorySeverity

func CategorySeverity(category string) int

CategorySeverity returns a numeric value for category comparison (higher = worse)

Types

type BPGoal

type BPGoal struct {
	TargetSystolic  *int `json:"target_systolic,omitempty"`
	TargetDiastolic *int `json:"target_diastolic,omitempty"`
}

BP Goal Settings

type BPPeriodStats

type BPPeriodStats struct {
	Systolic  int `json:"systolic"`
	Diastolic int `json:"diastolic"`
	Days      int `json:"days"`     // Number of days with readings
	Readings  int `json:"readings"` // Total number of readings
}

BPPeriodStats represents daily-weighted BP stats for a specific time period

type BPReminderState

type BPReminderState struct {
	UserID                 int64      `json:"user_id"`
	Enabled                bool       `json:"enabled"`
	SnoozedUntil           *time.Time `json:"snoozed_until,omitempty"`
	DontRemindUntil        *time.Time `json:"dont_remind_until,omitempty"`
	LastNotificationSentAt *time.Time `json:"last_notification_sent_at,omitempty"`
	NotificationMessageID  *int       `json:"notification_message_id,omitempty"`
	PreferredReminderHour  int        `json:"preferred_reminder_hour"`
	CreatedAt              time.Time  `json:"created_at"`
	UpdatedAt              time.Time  `json:"updated_at"`
}

BPReminderState represents the state of BP reminders for a user

type BPStats

type BPStats struct {
	Stats14 *BPPeriodStats `json:"stats_14,omitempty"`
	Stats30 *BPPeriodStats `json:"stats_30,omitempty"`
	Stats60 *BPPeriodStats `json:"stats_60,omitempty"`
}

BPStats contains daily time-weighted blood pressure statistics for multiple time periods

type BloodPressure

type BloodPressure struct {
	ID         int64     `json:"id"`
	UserID     int64     `json:"user_id"`
	MeasuredAt time.Time `json:"measured_at"`
	Systolic   int       `json:"systolic"`
	Diastolic  int       `json:"diastolic"`
	Pulse      *int      `json:"pulse,omitempty"`
	Site       string    `json:"site,omitempty"`
	Position   string    `json:"position,omitempty"`
	Category   string    `json:"category,omitempty"`
	IgnoreCalc bool      `json:"ignore_calc"`
	Notes      string    `json:"notes,omitempty"`
	Tag        string    `json:"tag,omitempty"`
}

type IntakeLog

type IntakeLog struct {
	ID           int64      `json:"id"`
	MedicationID int64      `json:"medication_id"`
	UserID       int64      `json:"user_id"`
	ScheduledAt  time.Time  `json:"scheduled_at"`
	TakenAt      *time.Time `json:"taken_at,omitempty"`
	Status       string     `json:"status"` // PENDING, TAKEN, MISSED
}

type IntakeWithMedication

type IntakeWithMedication struct {
	IntakeLog
	MedicationName   string `json:"medication_name"`
	MedicationDosage string `json:"medication_dosage"`
}

type Medication

type Medication struct {
	ID             int64      `json:"id"`
	Name           string     `json:"name"`
	Dosage         string     `json:"dosage"`
	Schedule       string     `json:"schedule"` // e.g. "09:00" or JSON
	Archived       bool       `json:"archived"`
	StartDate      *time.Time `json:"start_date"`
	EndDate        *time.Time `json:"end_date"`
	LastTakenAt    *time.Time `json:"last_taken_at"`
	CreatedAt      time.Time  `json:"created_at"`
	RxCUI          string     `json:"rxcui,omitempty"`
	NormalizedName string     `json:"normalized_name,omitempty"`
	InventoryCount *int       `json:"inventory_count,omitempty"` // NULL = not tracking
}

func (*Medication) ValidSchedule

func (m *Medication) ValidSchedule() (*ScheduleConfig, error)

type PushSubscription

type PushSubscription struct {
	ID        int64     `json:"id"`
	UserID    int64     `json:"user_id"`
	Endpoint  string    `json:"endpoint"`
	Auth      string    `json:"auth"`
	P256dh    string    `json:"p256dh"`
	Enabled   bool      `json:"enabled"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

PushSubscription represents a Web Push subscription

type Restock

type Restock struct {
	ID           int64     `json:"id"`
	MedicationID int64     `json:"medication_id"`
	Quantity     int       `json:"quantity"`
	Note         string    `json:"note,omitempty"`
	RestockedAt  time.Time `json:"restocked_at"`
}

type ScheduleConfig

type ScheduleConfig struct {
	Type  string   `json:"type"`            // "daily", "weekly", "as_needed"
	Days  []int    `json:"days,omitempty"`  // 0=Sunday, 1=Monday...
	Times []string `json:"times,omitempty"` // ["08:00", "20:00"]
}

type SleepLog

type SleepLog struct {
	ID             int64     `json:"id"`
	UserID         int64     `json:"user_id"`
	StartTime      time.Time `json:"start_time"`
	EndTime        time.Time `json:"end_time"`
	TimezoneOffset int       `json:"timezone_offset"`
	Day            string    `json:"day"`
	LightMinutes   *int      `json:"light_minutes,omitempty"`
	DeepMinutes    *int      `json:"deep_minutes,omitempty"`
	REMMinutes     *int      `json:"rem_minutes,omitempty"`
	AwakeMinutes   *int      `json:"awake_minutes,omitempty"`
	TotalMinutes   *int      `json:"total_minutes,omitempty"`
	TurnOverCount  *int      `json:"turn_over_count,omitempty"`
	HeartRateAvg   *int      `json:"heart_rate_avg,omitempty"`
	SpO2Avg        *int      `json:"spo2_avg,omitempty"`
	UserModified   bool      `json:"user_modified"`
	Notes          string    `json:"notes,omitempty"`
	CreatedAt      time.Time `json:"created_at"`
}

type Store

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

func New

func New(dbPath string) (*Store, error)

func (*Store) AddExerciseToVariant

func (s *Store) AddExerciseToVariant(variantID int64, exerciseName string, targetSets, targetRepsMin int, targetRepsMax *int, targetWeightKg *float64, orderIndex int) (*WorkoutExercise, error)

func (*Store) AddIntakeReminder

func (s *Store) AddIntakeReminder(intakeID int64, messageID int) error

func (*Store) AddRestock

func (s *Store) AddRestock(medID int64, qty int, note string) error

AddRestock adds inventory and logs the restock event

func (*Store) AdvanceRotation

func (s *Store) AdvanceRotation(groupID int64) error

func (*Store) CalculatePreferredReminderHour

func (s *Store) CalculatePreferredReminderHour(ctx context.Context, userID int64) (int, error)

CalculatePreferredReminderHour calculates the preferred reminder hour based on recent BP readings

func (*Store) CalculatePreferredWeightReminderHour

func (s *Store) CalculatePreferredWeightReminderHour(ctx context.Context, userID int64) (int, error)

CalculatePreferredWeightReminderHour calculates the preferred reminder hour based on recent weight logs Analyzes last 14 days of weight logs, averages the hour of measurement Constraints: 6 AM - 12 PM range (morning weigh-ins recommended) Default: 9 AM if < 3 measurements Rationale: Weight measurements are most accurate in morning (fasting state)

func (*Store) ClearSnooze

func (s *Store) ClearSnooze(id int64) error

func (*Store) Close

func (s *Store) Close() error

func (*Store) CompleteSession

func (s *Store) CompleteSession(id int64) error

func (*Store) ConfirmIntake

func (s *Store) ConfirmIntake(id int64, takenAt time.Time) error

func (*Store) ConfirmIntakesBySchedule

func (s *Store) ConfirmIntakesBySchedule(userID int64, scheduledAt time.Time, takenAt time.Time) error

func (*Store) CreateAdHocWorkoutSession

func (s *Store) CreateAdHocWorkoutSession(userID int64, scheduledDate time.Time, scheduledTime string) (*WorkoutSession, error)

CreateAdHocWorkoutSession creates an unscheduled workout session Uses -1 as sentinel values for group_id and variant_id

func (*Store) CreateBloodPressureReading

func (s *Store) CreateBloodPressureReading(ctx context.Context, bp *BloodPressure) (int64, error)

func (*Store) CreateGroupSnapshot

func (s *Store) CreateGroupSnapshot(groupID int64, snapshotData, changeReason string) error

func (*Store) CreateIntake

func (s *Store) CreateIntake(medID, userID int64, scheduledAt time.Time) (int64, error)

func (*Store) CreateMedication

func (s *Store) CreateMedication(name, dosage, schedule string, startDate, endDate *time.Time, rxcui, normalizedName string) (int64, error)

func (*Store) CreatePushSubscription

func (s *Store) CreatePushSubscription(userID int64, endpoint, auth, p256dh string) error

func (*Store) CreateWeightLog

func (s *Store) CreateWeightLog(ctx context.Context, w *WeightLog) (int64, error)

func (*Store) CreateWorkoutGroup

func (s *Store) CreateWorkoutGroup(name, description string, isRotating bool, userID int64, daysOfWeek string, scheduledTime string, notificationAdvance int) (*WorkoutGroup, error)

func (*Store) CreateWorkoutSession

func (s *Store) CreateWorkoutSession(groupID, variantID, userID int64, scheduledDate time.Time, scheduledTime string) (*WorkoutSession, error)

func (*Store) CreateWorkoutVariant

func (s *Store) CreateWorkoutVariant(groupID int64, name string, rotationOrder *int, description string) (*WorkoutVariant, error)

func (*Store) DecrementInventory

func (s *Store) DecrementInventory(medID int64, qty int) error

DecrementInventory reduces the inventory count by the given quantity Only decrements if inventory is being tracked (not NULL)

func (*Store) DeleteBloodPressureReading

func (s *Store) DeleteBloodPressureReading(ctx context.Context, id, userID int64) error

func (*Store) DeleteIntake

func (s *Store) DeleteIntake(id int64) error

func (*Store) DeleteMedication

func (s *Store) DeleteMedication(id int64) error

func (*Store) DeletePushSubscription

func (s *Store) DeletePushSubscription(endpoint string) error

func (*Store) DeleteWeightLog

func (s *Store) DeleteWeightLog(ctx context.Context, id, userID int64) error

func (*Store) DeleteWorkoutExercise

func (s *Store) DeleteWorkoutExercise(id int64) error

func (*Store) DeleteWorkoutVariant

func (s *Store) DeleteWorkoutVariant(id int64) error

func (*Store) DisablePushSubscription

func (s *Store) DisablePushSubscription(endpoint string) error

func (*Store) DontBugMeBPReminder

func (s *Store) DontBugMeBPReminder(userID int64) error

DontBugMeBPReminder disables BP reminders for 24 hours

func (*Store) DontBugMeWeightReminder

func (s *Store) DontBugMeWeightReminder(userID int64) error

DontBugMeWeightReminder disables weight reminders for 24 hours

func (*Store) GetActiveSessions

func (s *Store) GetActiveSessions(userID int64, date time.Time) ([]WorkoutSession, error)

GetActiveSessions returns all sessions for a given date that are in 'notified' or 'in_progress' status This is used to display workouts that have been notified but not yet started/completed, even if their scheduled time has passed

func (*Store) GetAllUniqueExercises

func (s *Store) GetAllUniqueExercises(userID int64) ([]WorkoutExercise, error)

GetAllUniqueExercises returns a deduplicated list of all exercises across all active workout groups for a user

func (*Store) GetBPDailyWeightedStats

func (s *Store) GetBPDailyWeightedStats(ctx context.Context, userID int64) (*BPStats, error)

GetBPDailyWeightedStats calculates daily time-weighted blood pressure averages. It weights each reading by the time until the next reading, computes a per-day time-weighted average, then averages daily averages across the period.

func (*Store) GetBPGoal

func (s *Store) GetBPGoal() (*BPGoal, error)

func (*Store) GetBPReminderState

func (s *Store) GetBPReminderState(userID int64) (*BPReminderState, error)

GetBPReminderState retrieves the BP reminder state for a user If no state exists, returns a default state with enabled=true

func (*Store) GetBloodPressureReadings

func (s *Store) GetBloodPressureReadings(ctx context.Context, userID int64, since time.Time) ([]BloodPressure, error)

func (*Store) GetDaysOfStockRemaining

func (s *Store) GetDaysOfStockRemaining(m *Medication) *float64

GetDaysOfStockRemaining calculates how many days of stock remain for a medication

func (*Store) GetDominantBPCategory

func (s *Store) GetDominantBPCategory(ctx context.Context, userID int64) (string, error)

GetDominantBPCategory calculates the dominant BP category over the last 14 days

func (*Store) GetExerciseLogs

func (s *Store) GetExerciseLogs(sessionID int64) ([]WorkoutExerciseLog, error)

func (*Store) GetGroupSnapshots

func (s *Store) GetGroupSnapshots(groupID int64) ([]WorkoutScheduleSnapshot, error)

func (*Store) GetHighestWeightRecord

func (s *Store) GetHighestWeightRecord(ctx context.Context, userID int64) (*WeightLog, error)

func (*Store) GetIntake

func (s *Store) GetIntake(id int64) (*IntakeLog, error)

func (*Store) GetIntakeBySchedule

func (s *Store) GetIntakeBySchedule(medID int64, scheduledAt time.Time) (*IntakeLog, error)

func (*Store) GetIntakeHistory

func (s *Store) GetIntakeHistory(medID int, days int) ([]IntakeLog, error)

func (*Store) GetIntakeReminders

func (s *Store) GetIntakeReminders(intakeID int64) ([]int, error)

func (*Store) GetIntakesSince

func (s *Store) GetIntakesSince(since time.Time) ([]IntakeWithMedication, error)

func (*Store) GetLastBPReading

func (s *Store) GetLastBPReading(ctx context.Context, userID int64) (*BloodPressure, error)

GetLastBPReading retrieves the most recent BP reading for a user

func (*Store) GetLastDownload

func (s *Store) GetLastDownload() (time.Time, error)

func (*Store) GetLastWeightLog

func (s *Store) GetLastWeightLog(ctx context.Context, userID int64) (*WeightLog, error)

func (*Store) GetMedication

func (s *Store) GetMedication(id int64) (*Medication, error)

func (*Store) GetMedicationsLowOnStock

func (s *Store) GetMedicationsLowOnStock(daysThreshold int) ([]Medication, error)

GetMedicationsLowOnStock returns medications with inventory tracking that are low on stock daysThreshold: warn if stock lasts fewer than this many days

func (*Store) GetPendingIntakes

func (s *Store) GetPendingIntakes() ([]IntakeLog, error)

func (*Store) GetPendingIntakesBySchedule

func (s *Store) GetPendingIntakesBySchedule(userID int64, scheduledAt time.Time) ([]IntakeLog, error)

func (*Store) GetPendingIntakesForMedication

func (s *Store) GetPendingIntakesForMedication(medID int64) ([]IntakeLog, error)

func (*Store) GetPushSubscriptions

func (s *Store) GetPushSubscriptions(userID int64) ([]PushSubscription, error)

func (*Store) GetRestockHistory

func (s *Store) GetRestockHistory(medID int64) ([]Restock, error)

GetRestockHistory returns restock events for a medication

func (*Store) GetRotationState

func (s *Store) GetRotationState(groupID int64) (*WorkoutRotationState, error)

func (*Store) GetSessionByGroupAndDate

func (s *Store) GetSessionByGroupAndDate(groupID int64, scheduledDate time.Time) (*WorkoutSession, error)

func (*Store) GetSleepLogs

func (s *Store) GetSleepLogs(ctx context.Context, userID int64, since time.Time) ([]SleepLog, error)

GetSleepLogs retrieves sleep logs for a user since a given date

func (*Store) GetSnoozedSessions

func (s *Store) GetSnoozedSessions(userID int64) ([]WorkoutSession, error)

func (*Store) GetUsersForBPReminders

func (s *Store) GetUsersForBPReminders() ([]int64, error)

GetUsersForBPReminders returns users who have BP reminders enabled

func (*Store) GetUsersForWeightReminders

func (s *Store) GetUsersForWeightReminders() ([]int64, error)

GetUsersForWeightReminders returns users who have weight reminders enabled

func (*Store) GetWeightGoal

func (s *Store) GetWeightGoal() (*WeightGoal, error)

func (*Store) GetWeightLogs

func (s *Store) GetWeightLogs(ctx context.Context, userID int64, since time.Time) ([]WeightLog, error)

func (*Store) GetWeightReminderState

func (s *Store) GetWeightReminderState(userID int64) (*WeightReminderState, error)

GetWeightReminderState retrieves the weight reminder state for a user If no state exists, returns a default state with enabled=true

func (*Store) GetWorkoutExercise

func (s *Store) GetWorkoutExercise(id int64) (*WorkoutExercise, error)

func (*Store) GetWorkoutGroup

func (s *Store) GetWorkoutGroup(id int64) (*WorkoutGroup, error)

func (*Store) GetWorkoutHistory

func (s *Store) GetWorkoutHistory(userID int64, limit int) ([]WorkoutSession, error)

func (*Store) GetWorkoutSession

func (s *Store) GetWorkoutSession(id int64) (*WorkoutSession, error)

func (*Store) GetWorkoutVariant

func (s *Store) GetWorkoutVariant(id int64) (*WorkoutVariant, error)

func (*Store) ImportBloodPressureReadings

func (s *Store) ImportBloodPressureReadings(ctx context.Context, userID int64, readings []BloodPressure) error

func (*Store) ImportSleepLogs

func (s *Store) ImportSleepLogs(ctx context.Context, userID int64, logs []SleepLog) (int, int, error)

func (*Store) InitializeRotation

func (s *Store) InitializeRotation(groupID, startingVariantID int64) error

func (*Store) IsAdHocSession

func (s *Store) IsAdHocSession(sessionID int64) (bool, error)

IsAdHocSession checks if session is ad-hoc (group_id == -1)

func (*Store) IsLowOnStock

func (s *Store) IsLowOnStock(m *Medication, daysThreshold int) bool

IsLowOnStock checks if a medication is low on stock considering its end date

func (*Store) ListExercisesByVariant

func (s *Store) ListExercisesByVariant(variantID int64) ([]WorkoutExercise, error)

func (*Store) ListMedications

func (s *Store) ListMedications(showArchived bool) ([]Medication, error)

func (*Store) ListVariantsByGroup

func (s *Store) ListVariantsByGroup(groupID int64) ([]WorkoutVariant, error)

func (*Store) ListWorkoutGroups

func (s *Store) ListWorkoutGroups(userID int64, activeOnly bool) ([]WorkoutGroup, error)

func (*Store) LogExercise

func (s *Store) LogExercise(sessionID, exerciseID int64, exerciseName string, setsCompleted, repsCompleted *int, weightKg *float64, status, notes string) (int64, error)

func (*Store) SetBPGoal

func (s *Store) SetBPGoal(targetSystolic, targetDiastolic int) error

func (*Store) SetBPReminderEnabled

func (s *Store) SetBPReminderEnabled(userID int64, enabled bool) error

SetBPReminderEnabled enables or disables BP reminders for a user

func (*Store) SetInventory

func (s *Store) SetInventory(medID int64, count *int) error

SetInventory sets the inventory count for a medication (nil to disable tracking)

func (*Store) SetSessionNotificationMessageID

func (s *Store) SetSessionNotificationMessageID(id int64, messageID int) error

func (*Store) SetWeightGoal

func (s *Store) SetWeightGoal(weight float64, targetDate time.Time) error

func (*Store) SetWeightReminderEnabled

func (s *Store) SetWeightReminderEnabled(userID int64, enabled bool) error

SetWeightReminderEnabled enables or disables weight reminders for a user

func (*Store) SkipSession

func (s *Store) SkipSession(id int64) error

func (*Store) SnoozeBPReminder

func (s *Store) SnoozeBPReminder(userID int64) error

SnoozeBPReminder snoozes BP reminders for 2 hours

func (*Store) SnoozeSession

func (s *Store) SnoozeSession(id int64, snoozeDuration time.Duration) error

func (*Store) SnoozeWeightReminder

func (s *Store) SnoozeWeightReminder(userID int64) error

SnoozeWeightReminder snoozes weight reminders for 2 hours

func (*Store) StartSession

func (s *Store) StartSession(id int64) error

func (*Store) UpdateBPReminderNotificationSent

func (s *Store) UpdateBPReminderNotificationSent(userID int64, messageID *int) error

UpdateBPReminderNotificationSent records when a notification was sent

func (*Store) UpdateExerciseLog

func (s *Store) UpdateExerciseLog(id int64, setsCompleted, repsCompleted *int, weightKg *float64, notes string) error

func (*Store) UpdateIntake

func (s *Store) UpdateIntake(id int64, takenAt time.Time, status string) error

func (*Store) UpdateLastDownload

func (s *Store) UpdateLastDownload(t time.Time) error

func (*Store) UpdateMedication

func (s *Store) UpdateMedication(id int64, name, dosage, schedule string, archived bool, startDate, endDate *time.Time, rxcui, normalizedName string, inventoryCount *int) error

func (*Store) UpdatePreferredReminderHour

func (s *Store) UpdatePreferredReminderHour(userID int64, hour int) error

UpdatePreferredReminderHour updates the preferred reminder hour for a user

func (*Store) UpdatePreferredWeightReminderHour

func (s *Store) UpdatePreferredWeightReminderHour(userID int64, hour int) error

UpdatePreferredWeightReminderHour updates the preferred reminder hour for a user

func (*Store) UpdateSessionStatus

func (s *Store) UpdateSessionStatus(id int64, status string) error

func (*Store) UpdateWeightReminderNotificationSent

func (s *Store) UpdateWeightReminderNotificationSent(userID int64, messageID *int) error

UpdateWeightReminderNotificationSent records when a notification was sent

func (*Store) UpdateWorkoutExercise

func (s *Store) UpdateWorkoutExercise(id int64, exerciseName string, targetSets, targetRepsMin int, targetRepsMax *int, targetWeightKg *float64, orderIndex int) error

func (*Store) UpdateWorkoutGroup

func (s *Store) UpdateWorkoutGroup(id int64, name, description string, isRotating bool, daysOfWeek string, scheduledTime string, notificationAdvance int, active bool) error

func (*Store) UpdateWorkoutSessionNotes

func (s *Store) UpdateWorkoutSessionNotes(id int64, notes string) error

func (*Store) UpdateWorkoutVariant

func (s *Store) UpdateWorkoutVariant(id int64, name string, rotationOrder *int, description string) error

type WeightGoal

type WeightGoal struct {
	Goal     *float64   `json:"goal,omitempty"`
	GoalDate *time.Time `json:"goal_date,omitempty"`
}

Weight Goal Settings

type WeightLog

type WeightLog struct {
	ID              int64     `json:"id"`
	UserID          int64     `json:"user_id"`
	MeasuredAt      time.Time `json:"measured_at"`
	Weight          float64   `json:"weight"`
	WeightTrend     *float64  `json:"weight_trend,omitempty"`
	BodyFat         *float64  `json:"body_fat,omitempty"`
	BodyFatTrend    *float64  `json:"body_fat_trend,omitempty"`
	MuscleMass      *float64  `json:"muscle_mass,omitempty"`
	MuscleMassTrend *float64  `json:"muscle_mass_trend,omitempty"`
	Notes           string    `json:"notes,omitempty"`
}

type WeightReminderState

type WeightReminderState struct {
	UserID                 int64      `json:"user_id"`
	Enabled                bool       `json:"enabled"`
	SnoozedUntil           *time.Time `json:"snoozed_until,omitempty"`
	DontRemindUntil        *time.Time `json:"dont_remind_until,omitempty"`
	LastNotificationSentAt *time.Time `json:"last_notification_sent_at,omitempty"`
	NotificationMessageID  *int       `json:"notification_message_id,omitempty"`
	PreferredReminderHour  int        `json:"preferred_reminder_hour"`
	CreatedAt              time.Time  `json:"created_at"`
	UpdatedAt              time.Time  `json:"updated_at"`
}

WeightReminderState represents the state of weight reminders for a user

type WorkoutExercise

type WorkoutExercise struct {
	ID             int64    `json:"id"`
	VariantID      int64    `json:"variant_id"`
	ExerciseName   string   `json:"exercise_name"`
	TargetSets     int      `json:"target_sets"`
	TargetRepsMin  int      `json:"target_reps_min"`
	TargetRepsMax  *int     `json:"target_reps_max,omitempty"`
	TargetWeightKg *float64 `json:"target_weight_kg,omitempty"`
	OrderIndex     int      `json:"order_index"`
}

WorkoutExercise represents an exercise within a variant

type WorkoutExerciseLog

type WorkoutExerciseLog struct {
	ID            int64     `json:"id"`
	SessionID     int64     `json:"session_id"`
	ExerciseID    int64     `json:"exercise_id"`
	ExerciseName  string    `json:"exercise_name"`
	SetsCompleted *int      `json:"sets_completed,omitempty"`
	RepsCompleted *int      `json:"reps_completed,omitempty"`
	WeightKg      *float64  `json:"weight_kg,omitempty"`
	Status        string    `json:"status"` // completed, skipped
	Notes         string    `json:"notes,omitempty"`
	LoggedAt      time.Time `json:"logged_at"`
}

WorkoutExerciseLog represents completion of a single exercise

type WorkoutGroup

type WorkoutGroup struct {
	ID                         int64     `json:"id"`
	Name                       string    `json:"name"`
	Description                string    `json:"description,omitempty"`
	IsRotating                 bool      `json:"is_rotating"`
	UserID                     int64     `json:"user_id"`
	DaysOfWeek                 string    `json:"days_of_week"` // JSON array
	ScheduledTime              string    `json:"scheduled_time"`
	NotificationAdvanceMinutes int       `json:"notification_advance_minutes"`
	Active                     bool      `json:"active"`
	CreatedAt                  time.Time `json:"created_at"`
	UpdatedAt                  time.Time `json:"updated_at"`
}

WorkoutGroup represents a workout group with schedule

type WorkoutRotationState

type WorkoutRotationState struct {
	GroupID          int64      `json:"group_id"`
	CurrentVariantID int64      `json:"current_variant_id"`
	LastSessionDate  *time.Time `json:"last_session_date,omitempty"`
	UpdatedAt        time.Time  `json:"updated_at"`
}

WorkoutRotationState tracks the current rotation position

type WorkoutScheduleSnapshot

type WorkoutScheduleSnapshot struct {
	ID           int64     `json:"id"`
	GroupID      int64     `json:"group_id"`
	SnapshotData string    `json:"snapshot_data"` // JSON
	ChangeReason string    `json:"change_reason,omitempty"`
	CreatedAt    time.Time `json:"created_at"`
}

WorkoutScheduleSnapshot represents a snapshot of a group's schedule

type WorkoutSession

type WorkoutSession struct {
	ID                    int64      `json:"id"`
	GroupID               int64      `json:"group_id"`   // -1 for ad-hoc workouts
	VariantID             int64      `json:"variant_id"` // -1 for ad-hoc workouts
	UserID                int64      `json:"user_id"`
	ScheduledDate         time.Time  `json:"scheduled_date"`
	ScheduledTime         string     `json:"scheduled_time"`
	Status                string     `json:"status"` // pending, notified, in_progress, completed, skipped
	StartedAt             *time.Time `json:"started_at,omitempty"`
	CompletedAt           *time.Time `json:"completed_at,omitempty"`
	SnoozedUntil          *time.Time `json:"snoozed_until,omitempty"`
	SnoozeCount           int        `json:"snooze_count"`
	NotificationMessageID *int       `json:"notification_message_id,omitempty"`
	Notes                 string     `json:"notes,omitempty"`
}

WorkoutSession represents an actual workout instance

type WorkoutVariant

type WorkoutVariant struct {
	ID            int64     `json:"id"`
	GroupID       int64     `json:"group_id"`
	Name          string    `json:"name"`
	RotationOrder *int      `json:"rotation_order,omitempty"` // NULL for non-rotating
	Description   string    `json:"description,omitempty"`
	CreatedAt     time.Time `json:"created_at"`
}

WorkoutVariant represents a workout variant (Day A, B, C, D or Default)

Jump to

Keyboard shortcuts

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