models

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = errors.New("not found")
	ErrUnauthorized = errors.New("unauthorized")
	ErrConflict     = errors.New("conflict")
	ErrValidation   = errors.New("validation error")
)

Functions

func PeriodBounds

func PeriodBounds(period string, now time.Time) (from, to *time.Time)

PeriodBounds returns the inclusive [start, end] window for a time-period token ("today", "week", "month"), computed in now's location with the week starting Monday. Any other value (including "all" or "") returns nil bounds, meaning no time restriction. This axis is independent of the pending/ completed/all status axis, so callers can combine them (e.g. completed this week).

func PriorityReminderInterval

func PriorityReminderInterval(p Priority) time.Duration

Types

type APIToken

type APIToken struct {
	ID          string
	UserID      string
	Name        string
	TokenPrefix string
	TokenHash   string
	LastUsedAt  *time.Time
	ExpiresAt   *time.Time
	CreatedAt   time.Time
	RevokedAt   *time.Time
}

func (*APIToken) Expired

func (t *APIToken) Expired(now time.Time) bool

func (*APIToken) Revoked

func (t *APIToken) Revoked() bool

type Locale

type Locale string
const (
	LocaleEn Locale = "en"
	LocaleEl Locale = "el"
)

func (Locale) Valid

func (l Locale) Valid() bool

type Priority

type Priority string
const (
	PriorityLow    Priority = "low"
	PriorityNormal Priority = "normal"
	PriorityHigh   Priority = "high"
)

func ParsePriority

func ParsePriority(s string) (Priority, error)

func (Priority) Icon

func (p Priority) Icon() string

func (Priority) Valid

func (p Priority) Valid() bool

type RecurrenceFreq

type RecurrenceFreq string
const (
	FreqDaily   RecurrenceFreq = "daily"
	FreqWeekly  RecurrenceFreq = "weekly"
	FreqMonthly RecurrenceFreq = "monthly"
	FreqYearly  RecurrenceFreq = "yearly"
)

func ParseRecurrenceFreq

func ParseRecurrenceFreq(s string) (RecurrenceFreq, error)

func (RecurrenceFreq) Valid

func (f RecurrenceFreq) Valid() bool

type Session

type Session struct {
	ID        string
	UserID    string
	TokenHash string
	UserAgent string
	CreatedAt time.Time
	ExpiresAt time.Time
}

func (*Session) Expired

func (s *Session) Expired(now time.Time) bool

type Task

type Task struct {
	ID                   string
	UserID               string
	Title                string
	Description          string
	Priority             Priority
	Kind                 TaskKind
	DueAt                time.Time
	DurationMinutes      int
	CompletedAt          *time.Time
	RecurrenceFreq       *RecurrenceFreq
	RecurrenceInterval   int
	RecurrenceByDay      string
	RecurrenceByMonthDay *int
	RecurrenceEndAt      *time.Time
	LastNotifiedAt       *time.Time
	SnoozedUntil         *time.Time
	CreatedAt            time.Time
	UpdatedAt            time.Time
}

func (*Task) Completed

func (t *Task) Completed() bool

func (*Task) Recurring

func (t *Task) Recurring() bool

func (*Task) Snoozed

func (t *Task) Snoozed(now time.Time) bool

type TaskCompletion

type TaskCompletion struct {
	ID          string
	TaskID      string
	UserID      string
	Title       string
	Priority    Priority
	DueAt       time.Time
	CompletedAt time.Time
	CreatedAt   time.Time
}

type TaskFilter

type TaskFilter struct {
	View   string
	Filter string
	From   *time.Time
	To     *time.Time
	// CompletedFrom/CompletedTo bound completed_at (used for "completed" +
	// a time period, e.g. "what did I finish this week").
	CompletedFrom *time.Time
	CompletedTo   *time.Time
	Priority      *Priority
	Month         *time.Time
	Limit         int
	Cursor        string
}

func (*TaskFilter) ApplyPeriod

func (f *TaskFilter) ApplyPeriod(period string, now time.Time)

ApplyPeriod restricts the filter to a time period, independently of its status. For "completed" the window bounds completed_at ("finished during the period"); otherwise it upper-bounds due_at so pending views still include overdue tasks up to the end of the period. An empty/"all" period is a no-op.

type TaskKind

type TaskKind string
const (
	KindOneoff    TaskKind = "oneoff"
	KindRecurring TaskKind = "recurring"
)

type Theme

type Theme string
const (
	ThemeSystem Theme = "system"
	ThemeLight  Theme = "light"
	ThemeDark   Theme = "dark"
)

func (Theme) Valid

func (t Theme) Valid() bool

type User

type User struct {
	ID                   string
	Email                string
	PasswordHash         string
	DisplayName          string
	Timezone             string
	Locale               Locale
	Theme                Theme
	TelegramBotToken     string
	TelegramAllowedIDs   string
	TelegramChatID       string
	TelegramChatUserID   string
	TelegramConfiguredAt *time.Time
	CreatedAt            time.Time
	UpdatedAt            time.Time
	DeletedAt            *time.Time
}

func (*User) Deleted

func (u *User) Deleted() bool

func (*User) TelegramEnabled

func (u *User) TelegramEnabled() bool

func (*User) TelegramLinked

func (u *User) TelegramLinked() bool

Jump to

Keyboard shortcuts

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