model

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Book

type Book struct {
	ID                     int
	Title                  string
	Authors                []string
	Pages                  int
	Slug                   string
	ImageURL               string
	Rating                 float64
	RatingsCount           int
	ReviewsCount           int
	UsersCount             int
	UsersReadCount         int
	ReleaseDate            string
	FeaturedSeries         string
	FeaturedSeriesPosition int
}

Book represents a book from Hardcover.

func (Book) AuthorString

func (b Book) AuthorString() string

AuthorString returns authors joined by ", ".

type DayActivity

type DayActivity struct {
	Date    time.Time
	Minutes int
}

DayActivity represents total reading minutes for a single day.

type PageUpdate

type PageUpdate struct {
	Absolute int  // target page (if not relative)
	Delta    int  // delta (if relative)
	Relative bool // true if +N or -N
}

PageUpdate represents a parsed page update instruction.

func ParsePage

func ParsePage(s string) (PageUpdate, error)

ParsePage parses a page string: "123", "+10", "-5".

func (PageUpdate) Resolve

func (p PageUpdate) Resolve(currentPage, totalPages int) int

Resolve computes the final page number given the current page and total.

type ReadingSession

type ReadingSession struct {
	ID        int
	BookID    int // 0 = no book associated
	StartedAt time.Time
	EndedAt   *time.Time // nil = still running (should not be stored without end)
	Notes     string
	BookTitle string // denormalized for display
}

ReadingSession represents a timed reading session stored locally.

func (ReadingSession) Duration

func (s ReadingSession) Duration() time.Duration

Duration returns the session duration. Returns zero if EndedAt is nil.

type SearchMode

type SearchMode string

SearchMode represents a discovery intent in search.

const (
	SearchModeBook   SearchMode = "book"
	SearchModeAuthor SearchMode = "author"
	SearchModeGenre  SearchMode = "genre"
)

func ParseSearchMode

func ParseSearchMode(raw string) (SearchMode, error)

ParseSearchMode parses a user-facing search mode value.

func (SearchMode) Description

func (m SearchMode) Description() string

Description returns the applied discovery strategy.

func (SearchMode) Label

func (m SearchMode) Label() string

Label returns a compact uppercase label suitable for badges.

func (SearchMode) Next

func (m SearchMode) Next() SearchMode

Next cycles through modes in a deterministic order.

type SearchResult

type SearchResult struct {
	ID       int
	Title    string
	Authors  []string
	Pages    int
	Slug     string
	ImageURL string
	Rating   float64
	Ratings  int
}

SearchResult represents a book from the search API.

type Status

type Status int

Status represents a user-book status on Hardcover.

const (
	StatusWantToRead       Status = 1 // "oku"
	StatusCurrentlyReading Status = 2 // "reading"
	StatusRead             Status = 3 // "finished"
	StatusPaused           Status = 4
	StatusDidNotFinish     Status = 5 // "dnf"
	StatusIgnored          Status = 6
)

func StatusFromString

func StatusFromString(s string) (Status, error)

StatusFromString maps CLI aliases to status IDs.

func (Status) Label

func (s Status) Label() string

Label returns a human-readable display label.

func (Status) String

func (s Status) String() string

String returns the CLI-friendly name.

type StreakInfo

type StreakInfo struct {
	Current   int  // consecutive days ending today or yesterday
	Longest   int  // longest streak ever
	Total     int  // total days with at least one session
	ReadToday bool // whether there's a completed session today
}

StreakInfo holds computed streak statistics.

type TimerState

type TimerState struct {
	BookID    int       `json:"book_id"`
	StartedAt time.Time `json:"started_at"`
}

TimerState represents the currently running timer, stored as JSON in the state KV table.

type UserBook

type UserBook struct {
	ID            int
	BookID        int
	StatusID      Status
	CurrentPage   int
	Book          Book
	UserBookReads []UserBookRead
	UpdatedAt     time.Time
}

UserBook represents the user's relationship with a book.

func (UserBook) Progress

func (ub UserBook) Progress() string

Progress returns current page / total pages as a string.

type UserBookRead

type UserBookRead struct {
	ID            int
	UserBookID    int
	ProgressPages int
	StartedAt     *time.Time
	FinishedAt    *time.Time
}

UserBookRead represents a reading session/progress entry.

type WeeklyStats

type WeeklyStats struct {
	Days       [7]int // minutes per day (Mon=0 .. Sun=6)
	Total      int    // total minutes in the period
	Sessions   int    // total number of sessions
	LongestDay int    // index of day with most reading
}

WeeklyStats holds aggregated stats for a time period.

Jump to

Keyboard shortcuts

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