Documentation
¶
Overview ¶
Package db keeps persistence syntax: https://github.com/mattn/go-sqlite3/blob/master/_example/simple/simple.go driver: https://pkg.go.dev/modernc.org/sqlite
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrWindowNameRequired is a preflight check before window db operations ErrWindowNameRequired = errors.New("cannot do operations on a nameless window") // ErrZeroID is used when an ID is expected, e.g. a read did not scan an ID ErrZeroID = errors.New("failed to read record id was zero") // ErrMissingValue is used when a value is missing, e.g. a read did not scan ErrMissingValue = errors.New("missing an expected value") // ErrUnexpectedValue is used when a value is not met, e.g. an update was incomplete ErrUnexpectedValue = errors.New("expected value was not met") // DBName is the filename of the sqlite file for standard operation DBName = ".focustime.db" // DBNameTest is the filename of the sqlite file for tests, distinct to allow for dropping DBNameTest = ".focustime_test.db" // CSVFileName is the filename of the csv document generated CSVFileName = "focustime.csv" )
Functions ¶
This section is empty.
Types ¶
type Database ¶
Database stores the database connection and name
func DefaultSqliteConn ¶
DefaultSqliteConn provides a connection for standard operation
func (*Database) PrintGroupedReport ¶
func (db *Database) PrintGroupedReport(filter ReportFilter)
PrintGroupedReport will print a report of focused windows, grouped by suffix
func (*Database) Report ¶
func (db *Database) Report(filter ReportFilter) (*Report, error)
Report provides all records with at least certain amount of duration time tracked
func (*Database) SaveChange ¶
SaveChange will, given a title and seconds, create or update records accordingly
func (*Database) WriteCSV ¶
func (db *Database) WriteCSV(filter ReportFilter)
WriteCSV will write a report of focused windows, grouped by suffix, to current working dir
type DayWindow ¶
DayWindow is a database record
func NewDayWindow ¶
NewDayWindow is a associative database record of a particular day and window
type Report ¶
type Report struct {
Items []ReportItem
}
Report is a report derived from joined tables
func (*Report) GroupedByTitleSuffix ¶
func (r *Report) GroupedByTitleSuffix() map[string][]ReportItem
GroupedByTitleSuffix will attempt to group items by their suffix according to common delimiters
type ReportFilter ¶
type ReportFilter struct {
// contains filtered or unexported fields
}
ReportFilter is the filters that can be applied to a report
func NewReportFilter ¶
func NewReportFilter(startDateStr, endDateStr *string, duration *time.Duration) ReportFilter
NewReportFilter takes in flags and generates a report filter that can be used
type ReportItem ¶
ReportItem is an item in a report