Documentation ¶
Index ¶
- Constants
- func Itob(v int) []byte
- type CostUsage
- type Slice
- type StopwatchDB
- func (db *StopwatchDB) AddGroup(group string) (*model.Group, error)
- func (db *StopwatchDB) AddTask(group int, task, costcode string) (*model.Task, error)
- func (db *StopwatchDB) Close() error
- func (db *StopwatchDB) GetActiveTask() (*model.Task, error)
- func (db *StopwatchDB) GetGroup(group int) (*model.Group, error)
- func (db *StopwatchDB) GetSlices(group int, start, end time.Time) ([]TaskSlices, error)
- func (db *StopwatchDB) GetTask(group, task int) (*model.Task, error)
- func (db *StopwatchDB) GetUsage(group int, start, end time.Time) (*UsageReport, error)
- func (db *StopwatchDB) IsOpen() bool
- func (db *StopwatchDB) Open(path string) error
- func (db *StopwatchDB) ReadGroups() ([]model.Group, error)
- func (db *StopwatchDB) ReadHistory() ([]model.Task, error)
- func (db *StopwatchDB) ReadTask(group, task int) (*model.Task, error)
- func (db *StopwatchDB) ReadTasks(group int) ([]*model.Task, error)
- func (db *StopwatchDB) RemoveSlice(groupID, taskID int, start time.Time) (*model.Task, error)
- func (db *StopwatchDB) SaveGroup(group *model.Group) error
- func (db *StopwatchDB) SaveHistory(history []model.HistoryTask) error
- func (db *StopwatchDB) SaveTask(task *model.Task) error
- func (db *StopwatchDB) SetActiveTask(group, task int) error
- func (db *StopwatchDB) SetSlice(groupID, taskID int, start, end time.Time) (*model.Task, error)
- func (db *StopwatchDB) StartTask(group, task int) (*model.Task, error)
- func (db *StopwatchDB) StopTask(group, task int) (*model.Task, error)
- type TaskSlices
- type Usage
- type UsageReport
Constants ¶
const ( BucketTasks = "tasks" BucketGroups = "groups" BucketState = "state" BucketSlices = "slices" BucketHistory = "history" )
Bucket names
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CostUsage ¶
type CostUsage struct { CostCode string Usage []Usage Total model.TaskDuration }
CostUsage is time used per cost code over a period of time
type StopwatchDB ¶
type StopwatchDB struct {
// contains filtered or unexported fields
}
StopwatchDB is a handle for accessing a stopwatch database
func (*StopwatchDB) AddGroup ¶
func (db *StopwatchDB) AddGroup(group string) (*model.Group, error)
AddGroup adds a group, using given name
func (*StopwatchDB) AddTask ¶
AddTask adds a task for group, using given cost code to classify time spent
func (*StopwatchDB) GetActiveTask ¶
func (db *StopwatchDB) GetActiveTask() (*model.Task, error)
GetActiveTask returns currently active task, if one is set
func (*StopwatchDB) GetGroup ¶
func (db *StopwatchDB) GetGroup(group int) (*model.Group, error)
GetGroup returns one group details
func (*StopwatchDB) GetSlices ¶
func (db *StopwatchDB) GetSlices(group int, start, end time.Time) ([]TaskSlices, error)
GetSlices returns a report of slices recorded for a group between given start and end times.
func (*StopwatchDB) GetTask ¶
func (db *StopwatchDB) GetTask(group, task int) (*model.Task, error)
GetTask returns one task details
func (*StopwatchDB) GetUsage ¶
func (db *StopwatchDB) GetUsage(group int, start, end time.Time) (*UsageReport, error)
GetUsage returns a report of time used for a group during given period of time.
func (*StopwatchDB) IsOpen ¶
func (db *StopwatchDB) IsOpen() bool
IsOpen returns if database is open.
func (*StopwatchDB) Open ¶
func (db *StopwatchDB) Open(path string) error
Open opens a database and initializes it
func (*StopwatchDB) ReadGroups ¶
func (db *StopwatchDB) ReadGroups() ([]model.Group, error)
ReadGroups returns all groups
func (*StopwatchDB) ReadHistory ¶
func (db *StopwatchDB) ReadHistory() ([]model.Task, error)
ReadHistory returns last known task usage history
func (*StopwatchDB) ReadTask ¶
func (db *StopwatchDB) ReadTask(group, task int) (*model.Task, error)
ReadTask return a task
func (*StopwatchDB) ReadTasks ¶
func (db *StopwatchDB) ReadTasks(group int) ([]*model.Task, error)
ReadTasks return all tasks for a group
func (*StopwatchDB) RemoveSlice ¶
RemoveSlice deletes a slice from task. Task time used is updated to reflect the change. Returns changed Task on success.
func (*StopwatchDB) SaveGroup ¶
func (db *StopwatchDB) SaveGroup(group *model.Group) error
SaveGroup updates group value in database to the given value
func (*StopwatchDB) SaveHistory ¶
func (db *StopwatchDB) SaveHistory(history []model.HistoryTask) error
SaveHistory updates task history to given value
func (*StopwatchDB) SaveTask ¶
func (db *StopwatchDB) SaveTask(task *model.Task) error
SaveTask updates task value in database to the given value
func (*StopwatchDB) SetActiveTask ¶
func (db *StopwatchDB) SetActiveTask(group, task int) error
SetActiveTask sets currently active task, if one is set
func (*StopwatchDB) SetSlice ¶
SetSlice sets a slice for a task in a group and updates time used for the task. Overwrites if a slice exists with the given start time. Returns updated task on success
type TaskSlices ¶
type TaskSlices struct { // Task name Name string // ID is task ID ID int // Slices are tasks slices Slices []Slice }
TaskSlices reports a single tasks slices
type Usage ¶
type Usage struct { Date string Used model.TaskDuration }
Usage is the time used for a date
type UsageReport ¶
type UsageReport struct { // Dates is an array with the dates in the report Dates []Usage // CostCodes contains the time used per cost code CostCodes []CostUsage // Combined is the combined total time used Combined model.TaskDuration }
UsageReport is a time usage report. Contains work for one group.