Documentation
¶
Overview ¶
Package db handles the database connection and initialization.
Index ¶
- Constants
- func Connect() (*sqlx.DB, error)
- type AllTimeStats
- type DailyStat
- type Session
- type SessionRepo
- func (r *SessionRepo) CreateSession(startedAt time.Time, duration time.Duration, sessionType SessionType) error
- func (r *SessionRepo) GetAllTimeStats() (AllTimeStats, error)
- func (r *SessionRepo) GetLastMonthsStats(numberOfMonths int) ([]DailyStat, error)
- func (r *SessionRepo) GetStreakStats() (StreakStats, error)
- func (r *SessionRepo) GetWeeklyStats() ([]DailyStat, error)
- type SessionType
- type StreakStats
Constants ¶
View Source
const DBFile = config.AppName + ".db"
View Source
const DateFormat = "2006-01-02"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AllTimeStats ¶
type SessionRepo ¶
type SessionRepo struct {
// contains filtered or unexported fields
}
func NewSessionRepo ¶
func NewSessionRepo(db *sqlx.DB) *SessionRepo
func (*SessionRepo) CreateSession ¶
func (r *SessionRepo) CreateSession(startedAt time.Time, duration time.Duration, sessionType SessionType) error
CreateSession inserts a new session record into the database.
func (*SessionRepo) GetAllTimeStats ¶
func (r *SessionRepo) GetAllTimeStats() (AllTimeStats, error)
GetAllTimeStats retrieves aggregate statistics across all sessions.
func (*SessionRepo) GetLastMonthsStats ¶
func (r *SessionRepo) GetLastMonthsStats(numberOfMonths int) ([]DailyStat, error)
GetLastMonthsStats retrieves daily work duration statistics for the past specified number of months.
func (*SessionRepo) GetStreakStats ¶
func (r *SessionRepo) GetStreakStats() (StreakStats, error)
GetStreakStats calculates the current and best streaks of consecutive work days. A streak is consecutive days with at least one 'work' session.
func (*SessionRepo) GetWeeklyStats ¶
func (r *SessionRepo) GetWeeklyStats() ([]DailyStat, error)
GetWeeklyStats retrieves daily work duration statistics for the past 7 days.
type SessionType ¶
type SessionType string
const ( WorkSession SessionType = "work" BreakSession SessionType = "break" )
func GetSessionType ¶
func GetSessionType(taskType config.TaskType) SessionType
type StreakStats ¶
Click to show internal directories.
Click to hide internal directories.