Documentation
¶
Index ¶
- Constants
- Variables
- func GetBackupDir() (string, error)
- func GetDBPath() (string, error)
- func RestoreBackup(backupPath string) error
- type ActionType
- type BackupInfo
- type Database
- func (d *Database) ClearLastAction() error
- func (d *Database) Close() error
- func (d *Database) CreateBackup() (*BackupInfo, error)
- func (d *Database) CreateEntry(projectName, description string, hourlyRate *float64, milestoneName *string) (*TimeEntry, error)
- func (d *Database) CreateManualEntry(projectName, description string, startTime, endTime time.Time, ...) (*TimeEntry, error)
- func (d *Database) CreateMilestone(projectName, name string) (*Milestone, error)
- func (d *Database) DeleteTimeEntry(id int64) error
- func (d *Database) FinishMilestone(id int64) error
- func (d *Database) GetActiveMilestoneForProject(projectName string) (*Milestone, error)
- func (d *Database) GetAllMilestones() ([]*Milestone, error)
- func (d *Database) GetAllProjects() ([]string, error)
- func (d *Database) GetCompletedEntriesByProject(projectName string) ([]*TimeEntry, error)
- func (d *Database) GetEntries(limit int) ([]*TimeEntry, error)
- func (d *Database) GetEntriesByDateRange(start, end time.Time) ([]*TimeEntry, error)
- func (d *Database) GetEntriesByMilestone(projectName, milestoneName string) ([]*TimeEntry, error)
- func (d *Database) GetEntriesByProject(projectName string) ([]*TimeEntry, error)
- func (d *Database) GetEntry(id int64) (*TimeEntry, error)
- func (d *Database) GetLastAction() (*UndoAction, error)
- func (d *Database) GetLastStoppedEntry() (*TimeEntry, error)
- func (d *Database) GetLastStoppedEntryByProject(projectName string) (*TimeEntry, error)
- func (d *Database) GetMilestone(id int64) (*Milestone, error)
- func (d *Database) GetMilestoneByName(projectName, milestoneName string) (*Milestone, error)
- func (d *Database) GetMilestonesByProject(projectName string) ([]*Milestone, error)
- func (d *Database) GetProjectsWithCompletedEntries() ([]string, error)
- func (d *Database) GetRunningEntry() (*TimeEntry, error)
- func (d *Database) RestoreDeletedEntry(entry *TimeEntry) error
- func (d *Database) SaveLastAction(action UndoAction) error
- func (d *Database) StopEntry(id int64) error
- func (d *Database) UncompleteEntry(id int64) error
- func (d *Database) UpdateTimeEntry(id int64, entry *TimeEntry) error
- type Milestone
- type TimeEntry
- type UndoAction
Constants ¶
const (
Migration001_UTCTimestamps = "001_utc_timestamps"
)
Migration keys ! I'm adding this system so that future database migrations will be easier - Dylan
Variables ¶
var CurrentSchemaVersion = len(allMigrationKeys)
CurrentSchemaVersion is the number of migrations the current binary knows about.
Functions ¶
func GetBackupDir ¶ added in v0.7.0
func RestoreBackup ¶ added in v0.7.0
RestoreBackup copies a backup file over the live database. The caller must ensure no DB connection is open.
Types ¶
type ActionType ¶ added in v0.8.0
type ActionType string
const ( ActionStop ActionType = "stop" ActionStart ActionType = "start" ActionPause ActionType = "pause" ActionResume ActionType = "resume" ActionDelete ActionType = "delete" ActionManual ActionType = "manual" )
type BackupInfo ¶ added in v0.7.0
type BackupInfo struct {
ID int
Filename string
Path string
CreatedAt time.Time
Size int64
SchemaVersion int
IsUpToDate bool
}
func ListBackups ¶ added in v0.7.0
func ListBackups() ([]BackupInfo, error)
ListBackups returns all backups sorted newest-first with display IDs assigned (1 = newest).
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func Initialize ¶
func (*Database) ClearLastAction ¶ added in v0.8.0
func (*Database) CreateBackup ¶ added in v0.7.0
func (d *Database) CreateBackup() (*BackupInfo, error)
CreateBackup uses SQLite's VACUUM INTO to produce a clean, consistent snapshot of the live database.
func (*Database) CreateEntry ¶
func (*Database) CreateManualEntry ¶
func (*Database) CreateMilestone ¶ added in v0.3.0
func (*Database) DeleteTimeEntry ¶
func (*Database) FinishMilestone ¶ added in v0.3.0
func (*Database) GetActiveMilestoneForProject ¶ added in v0.3.0
func (*Database) GetAllMilestones ¶ added in v0.3.0
func (*Database) GetAllProjects ¶
func (*Database) GetCompletedEntriesByProject ¶
func (*Database) GetEntriesByDateRange ¶
func (*Database) GetEntriesByMilestone ¶ added in v0.3.0
func (*Database) GetEntriesByProject ¶
func (*Database) GetLastAction ¶ added in v0.8.0
func (d *Database) GetLastAction() (*UndoAction, error)
func (*Database) GetLastStoppedEntry ¶ added in v0.1.2
func (*Database) GetLastStoppedEntryByProject ¶ added in v0.4.5
func (*Database) GetMilestone ¶ added in v0.3.0
func (*Database) GetMilestoneByName ¶ added in v0.3.0
func (*Database) GetMilestonesByProject ¶ added in v0.3.0
func (*Database) GetProjectsWithCompletedEntries ¶
func (*Database) GetRunningEntry ¶
func (*Database) RestoreDeletedEntry ¶ added in v0.8.0
RestoreDeletedEntry re-inserts a previously deleted entry preserving its original ID.
func (*Database) SaveLastAction ¶ added in v0.8.0
func (d *Database) SaveLastAction(action UndoAction) error
func (*Database) UncompleteEntry ¶ added in v0.8.0
UncompleteEntry clears the end_time of an entry, resuming it as a running timer.
type Milestone ¶ added in v0.3.0
type TimeEntry ¶
type TimeEntry struct {
ID int64
ProjectName string
StartTime time.Time
EndTime *time.Time
Description string
HourlyRate *float64
MilestoneName *string
}
func (*TimeEntry) RoundedHours ¶ added in v0.1.3
RoundedHours returns duration in hours rounded to 2 decimal places for billing. Could be made configurable to support different rounding increments (0.1h, 0.25h, etc).
type UndoAction ¶ added in v0.8.0
type UndoAction struct {
Type ActionType `json:"type"`
EntryID int64 `json:"entry_id,omitempty"`
ProjectName string `json:"project_name,omitempty"`
Entry *TimeEntry `json:"entry,omitempty"`
}