stopwatchdb

package
v0.0.0-...-ea70059 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BucketTasks   = "tasks"
	BucketGroups  = "groups"
	BucketState   = "state"
	BucketSlices  = "slices"
	BucketHistory = "history"
)

Bucket names

Variables

This section is empty.

Functions

func Itob

func Itob(v int) []byte

Itob returns an 8-byte big endian representation of v.

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 Slice

type Slice struct {
	Start time.Time
	End   time.Time
}

Slice documents a single period of work

type StopwatchDB

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

StopwatchDB is a handle for accessing a stopwatch database

func New

func New() *StopwatchDB

New return an initialized stopwatch db

func (*StopwatchDB) AddGroup

func (db *StopwatchDB) AddGroup(group string) (*model.Group, error)

AddGroup adds a group, using given name

func (*StopwatchDB) AddTask

func (db *StopwatchDB) AddTask(group int, task, costcode string) (*model.Task, error)

AddTask adds a task for group, using given cost code to classify time spent

func (*StopwatchDB) Close

func (db *StopwatchDB) Close() error

Close closes current DB handle

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

func (db *StopwatchDB) RemoveSlice(groupID, taskID int, start time.Time) (*model.Task, error)

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

func (db *StopwatchDB) SetSlice(groupID, taskID int, start, end time.Time) (*model.Task, error)

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

func (*StopwatchDB) StartTask

func (db *StopwatchDB) StartTask(group, task int) (*model.Task, error)

StartTask marks tasks start

func (*StopwatchDB) StopTask

func (db *StopwatchDB) StopTask(group, task int) (*model.Task, error)

StopTask marks task stop event

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.

Jump to

Keyboard shortcuts

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