storage

package
v0.0.0-...-5911d88 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresRepository

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

func NewPostgresRepository

func NewPostgresRepository(connStr string) (*PostgresRepository, error)

func (*PostgresRepository) Close

func (r *PostgresRepository) Close() error

func (*PostgresRepository) GetRecentSessions

func (r *PostgresRepository) GetRecentSessions(userID string, since time.Time) ([]SessionRecord, error)

func (*PostgresRepository) GetSessionStats

func (r *PostgresRepository) GetSessionStats(userID string) (*SessionStats, error)

func (*PostgresRepository) GetSessionsByUser

func (r *PostgresRepository) GetSessionsByUser(userID string) ([]SessionRecord, error)

func (*PostgresRepository) SaveSession

func (r *PostgresRepository) SaveSession(record *SessionRecord) error

type Repository

type Repository interface {
	SaveSession(record *SessionRecord) error

	GetSessionsByUser(userID string) ([]SessionRecord, error)

	GetRecentSessions(userID string, since time.Time) ([]SessionRecord, error)

	GetSessionStats(userID string) (*SessionStats, error)

	Close() error
}

type SQLiteRepository

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

func NewSQLiteRepository

func NewSQLiteRepository(dbPath string) (*SQLiteRepository, error)

func (*SQLiteRepository) Close

func (r *SQLiteRepository) Close() error

func (*SQLiteRepository) GetRecentSessions

func (r *SQLiteRepository) GetRecentSessions(userID string, since time.Time) ([]SessionRecord, error)

func (*SQLiteRepository) GetSessionStats

func (r *SQLiteRepository) GetSessionStats(userID string) (*SessionStats, error)

func (*SQLiteRepository) GetSessionsByUser

func (r *SQLiteRepository) GetSessionsByUser(userID string) ([]SessionRecord, error)

func (*SQLiteRepository) SaveSession

func (r *SQLiteRepository) SaveSession(record *SessionRecord) error

type SessionRecord

type SessionRecord struct {
	ID          string
	UserID      string
	TargetSec   int
	Success     SuccessLevel
	Comment     string
	StartedAt   time.Time
	CompletedAt time.Time
	Steps       []StepRecord
}

func FromDomainSession

func FromDomainSession(s *domain.Session, success SuccessLevel, comment string) *SessionRecord

FromDomainSession converts a domain.Session to a SessionRecord

type SessionStats

type SessionStats struct {
	TotalSessions   int     `json:"totalSessions"`
	SuccessfulCount int     `json:"successfulCount"`
	AverageTarget   float64 `json:"averageTarget"`
	TotalTrainTime  int     `json:"totalTrainTime"`
	SuccessRate     float64 `json:"successRate"`
}

type StepRecord

type StepRecord struct {
	SessionID string
	Index     int
	Duration  int
	ActualSec int // How long it actually took (might be less if failed)
	Completed bool
}

type SuccessLevel

type SuccessLevel string
const (
	SuccessLevelFail  SuccessLevel = "fail"
	SuccessLevelOK    SuccessLevel = "ok"
	SuccessLevelGreat SuccessLevel = "great"
)

Jump to

Keyboard shortcuts

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