db

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath added in v1.4.0

func DefaultPath() (string, error)

DefaultPath returns the canonical clockwork database path. Honours the CLOCKWORK_DB env var, otherwise falls back to ~/.local/clockwork/default.db.

Types

type Statistics

type Statistics struct {
	TotalMinutes      int64            `json:"total_minutes"`
	TotalHours        float64          `json:"total_hours"`
	EntryCount        int              `json:"entry_count"`
	InvoicedMinutes   int64            `json:"invoiced_minutes"`
	UninvoicedMinutes int64            `json:"uninvoiced_minutes"`
	ProjectBreakdown  map[string]int64 `json:"project_breakdown"` // projectID -> minutes
	EarliestEntry     *time.Time       `json:"earliest_entry,omitempty"`
	LatestEntry       *time.Time       `json:"latest_entry,omitempty"`
}

Statistics represents aggregated entry statistics

type Store

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

Store manages database operations for clockwork

func New

func New(dbPath string) (*Store, error)

New creates a new Store instance and initializes the database

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection

func (*Store) CreateEntry

func (s *Store) CreateEntry(projectID string, duration int64, message, commitHash string, invoiced bool, createdAt time.Time) (*models.Entry, error)

CreateEntry creates a new worklog entry

func (*Store) CreateProject

func (s *Store) CreateProject(name, gitRepoPath string) (*models.Project, error)

CreateProject creates a new project

func (*Store) DeleteEntry

func (s *Store) DeleteEntry(id string) error

DeleteEntry deletes an entry

func (*Store) DeleteProject

func (s *Store) DeleteProject(id string) error

DeleteProject deletes a project and all its entries (single-pass cascade).

func (*Store) GetEntry

func (s *Store) GetEntry(id string) (*models.Entry, error)

GetEntry retrieves an entry by ID

func (*Store) GetLastCommitHash added in v1.3.3

func (s *Store) GetLastCommitHash(projectID string) (string, error)

GetLastCommitHash returns the most recent non-empty commit hash across all entries for a project in a single bucket pass.

func (*Store) GetLastEntry

func (s *Store) GetLastEntry(projectID string) (*models.Entry, error)

GetLastEntry returns the most recent entry for a project in a single pass.

func (*Store) GetProject

func (s *Store) GetProject(id string) (*models.Project, error)

GetProject retrieves a project by ID

func (*Store) GetStatistics

func (s *Store) GetStatistics(projectID string, startDate, endDate *time.Time, invoicedFilter *bool) (*Statistics, error)

GetStatistics calculates aggregated statistics with optional filtering

func (*Store) ListEntries

func (s *Store) ListEntries(projectID string) ([]*models.Entry, error)

ListEntries returns all entries for a project

func (*Store) ListEntriesFiltered

func (s *Store) ListEntriesFiltered(projectID string, startDate, endDate *time.Time, invoicedFilter *bool) ([]*models.Entry, error)

ListEntriesFiltered returns entries with optional filtering

func (*Store) ListProjects

func (s *Store) ListProjects() ([]*models.Project, error)

ListProjects returns all projects

func (*Store) UpdateEntry

func (s *Store) UpdateEntry(id string, duration *int64, message, commitHash *string, invoiced *bool, createdAt *time.Time) (*models.Entry, error)

UpdateEntry updates an existing entry

func (*Store) UpdateProject

func (s *Store) UpdateProject(id, name, gitRepoPath string) (*models.Project, error)

UpdateProject updates an existing project

Jump to

Keyboard shortcuts

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