Documentation ¶
Index ¶
Constants ¶
const (
// TL is the time layout we will use.
TL = "2006-01-02 15:04"
)
Variables ¶
var DB *gorm.DB
DB is the connection to gorm. Required to be exported so main.go can defer close the database.
var Setting setting
Setting will contain the only row from the settings table.
Functions ¶
Types ¶
type Entry ¶
type Entry struct { gorm.Model Name string `gorm:"index;unique;not null"` Details string Start time.Time End time.Time Task Task TaskID uint `gorm:"index;not null"` Project Project ProjectID uint `gorm:"index;not null"` TotalTime time.Duration }
Entry model.
var CurrentEntry Entry
CurrentEntry holds the struct of the currently highlighted entry.
func AllEntries ¶
AllEntries queries the database for, and returns, all entries after scanning them into a slice.
func GetEntry ¶
GetEntry queries the database for, and returns, one entry after scanning it into the struct.
func StartEntry ¶
StartEntry queries the database for one entry by name. If the record exists then it is returned; else, it will create the record and return that one. It takes a task and start time as arguments.
func StopEntry ¶
StopEntry updates the entry with the stopped time, duration, and details. It takes an entry struct and stop time as arguments.
func (Entry) HoursMinutes ¶
HoursMinutes takes an Entry{} and returns its hours and minutes, both as ints.
type Project ¶
type Project struct { gorm.Model Name string `gorm:"type:varchar(100);unique;not null"` Description string Tasks []Task Entries []Entry TotalTime time.Duration }
Project model.
var CurrentProject Project
CurrentProject holds the struct of the currently highlighted project.
func AddProject ¶
AddProject queries the database for one project by name (project names are unique). If the record exists then it is returned; else, it will create the record and return that one.
func AllProjects ¶
func AllProjects() []Project
AllProjects queries the database for, and returns, all projects after scanning them into a slice of structs.
func GetProject ¶
GetProject queries the database for, and returns, one project after scanning it into the struct.
func UpdateProject ¶
UpdateProject will update the project with values defined outside.
func (Project) HoursMinutes ¶
HoursMinutes takes all entries for a project and returns its hours and minutes, both as ints.
type Task ¶
type Task struct { gorm.Model Name string `gorm:"not null"` Description string Entries []Entry Project Project ProjectID uint `gorm:"index;not null"` TotalTime time.Duration }
Task model.
var CurrentTask Task
CurrentTask holds the struct of the currently highlighted task.
func AddTask ¶
AddTask queries the database for one project by name. If the record exists then it is returned; else, it will create the record and return that one.
func AllTasks ¶
AllTasks queries the database for, and returns, all tasks after scanning them into a slice.
func GetTask ¶
GetTask queries the database for, and returns, one task after scanning it into the struct.
func (Task) HoursMinutes ¶
HoursMinutes takes all entries for a task and returns its hours and minutes, both as ints.