reminder

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotificationTiers = []NotificationTier{
	{"24h", 24 * time.Hour, "notified_24h"},
	{"12h", 12 * time.Hour, "notified_12h"},
	{"3h", 3 * time.Hour, "notified_3h"},
	{"1h", 1 * time.Hour, "notified_1h"},
	{"10m", 10 * time.Minute, "notified_10m"},
	{"at_time", 0, "notified_at_time"},
}

Standard notification tiers

Functions

func FormatTimeUntil

func FormatTimeUntil(d time.Duration) string

FormatTimeUntil formats the time until a reminder in a human-readable way

Types

type NotificationTier

type NotificationTier struct {
	Name     string
	Duration time.Duration
	Field    string
}

NotificationTier represents a notification time before the reminder

type Reminder

type Reminder struct {
	ID             string    `json:"id"`
	Title          string    `json:"title"`
	Description    string    `json:"description"`
	RemindAt       time.Time `json:"remind_at"`
	Notified24h    bool      `json:"notified_24h"`
	Notified12h    bool      `json:"notified_12h"`
	Notified3h     bool      `json:"notified_3h"`
	Notified1h     bool      `json:"notified_1h"`
	Notified10m    bool      `json:"notified_10m"`
	NotifiedAtTime bool      `json:"notified_at_time"`
	Completed      bool      `json:"completed"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

Reminder represents a reminder in the system

type ReminderCallback

type ReminderCallback func(reminder *Reminder, tier string, timeUntil time.Duration)

ReminderCallback is called when a reminder notification should be sent

type Scheduler

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

Scheduler checks for upcoming reminders and triggers notifications

func NewScheduler

func NewScheduler(store *Store) *Scheduler

NewScheduler creates a new reminder scheduler

func (*Scheduler) SetCallback

func (s *Scheduler) SetCallback(cb ReminderCallback)

SetCallback sets the notification callback

func (*Scheduler) Start

func (s *Scheduler) Start()

Start begins the scheduler, checking every minute

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop stops the scheduler

type Store

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

Store handles reminder persistence

func NewStore

func NewStore(db *sql.DB) *Store

NewStore creates a new reminder store

func (*Store) Create

func (s *Store) Create(ctx context.Context, title, description string, remindAt time.Time) (*Reminder, error)

Create creates a new reminder

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, id string) error

Delete removes a reminder

func (*Store) FindByTitle

func (s *Store) FindByTitle(ctx context.Context, title string) ([]*Reminder, error)

FindByTitle finds reminders matching a title (case-insensitive partial match)

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (*Reminder, error)

Get retrieves a reminder by ID

func (*Store) GetPendingReminders

func (s *Store) GetPendingReminders(ctx context.Context) ([]*Reminder, error)

GetPendingReminders returns reminders that need notification checks

func (*Store) List

func (s *Store) List(ctx context.Context, includeCompleted bool) ([]*Reminder, error)

List returns all reminders, optionally filtered by completion status

func (*Store) MarkCompleted

func (s *Store) MarkCompleted(ctx context.Context, id string) error

MarkCompleted marks a reminder as completed

func (*Store) MarkNotified

func (s *Store) MarkNotified(ctx context.Context, id string, tier string) error

MarkNotified marks a specific notification tier as sent

func (*Store) Update

func (s *Store) Update(ctx context.Context, id string, title, description *string, remindAt *time.Time) (*Reminder, error)

Update updates a reminder

Jump to

Keyboard shortcuts

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