Documentation
¶
Index ¶
- type Task
- type TaskData
- func (td *TaskData) Clear()
- func (td *TaskData) Clone() Task
- func (td *TaskData) Create() error
- func (td *TaskData) Data() *TaskData
- func (td *TaskData) Delete() error
- func (td *TaskData) DisplayString() string
- func (td *TaskData) Equals(task Task) bool
- func (td *TaskData) FindTaskBySynopsis(tasks []TaskData, synopsis string) *TaskData
- func (td *TaskData) Load(withDeleted bool) error
- func (td *TaskData) LoadAll(withDeleted bool) ([]TaskData, error)
- func (td *TaskData) Resolve(arg string) (taskid uint, tasksynopsis string)
- func (td *TaskData) Search(text string) ([]TaskData, error)
- func (td *TaskData) SearchBySynopsis(synopsis string) ([]TaskData, error)
- func (td *TaskData) StopRunningTask() (timesheetData *TimesheetData, err error)
- func (td *TaskData) String() string
- func (td *TaskData) TableName() string
- func (td *TaskData) Update(withDeleted bool) error
- type TaskDatas
- type TaskList
- type TaskReport
- type TaskReportData
- type Timesheet
- type TimesheetData
- func (tsd *TimesheetData) CountOpen() (int, error)
- func (tsd *TimesheetData) Create() error
- func (tsd *TimesheetData) Data() *TimesheetData
- func (tsd *TimesheetData) Delete() error
- func (tsd *TimesheetData) Equals(other Timesheet) bool
- func (tsd *TimesheetData) LastStartedTasks(limit uint) (startedTasks []TaskData, err error)
- func (tsd *TimesheetData) Load() error
- func (tsd *TimesheetData) LoadAll(withDeleted bool) ([]TimesheetData, error)
- func (tsd *TimesheetData) RunningTimesheet() (Timesheet, error)
- func (tsd *TimesheetData) SearchDateRange(withDeleted bool) ([]TimesheetData, error)
- func (tsd *TimesheetData) SearchOpen() ([]TimesheetData, error)
- func (tsd *TimesheetData) String() string
- func (tsd *TimesheetData) TableName() string
- func (tsd *TimesheetData) TaskReport(startDate, endDate time.Time, withDeleted bool) (reportData TaskReport, err error)
- func (tsd *TimesheetData) Update() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Task ¶
type Task interface {
fmt.Stringer
schema.Tabler
Data() *TaskData
Create() error
Load(withDeleted bool) error
Update(withDeleted bool) error
Delete() error
Clear()
Clone() Task
LoadAll(withDeleted bool) ([]TaskData, error)
Search(text string) ([]TaskData, error)
SearchBySynopsis(synopsis string) ([]TaskData, error)
StopRunningTask() (*TimesheetData, error)
FindTaskBySynopsis(tasks []TaskData, synopsis string) *TaskData
Resolve(arg string) (uint, string)
DisplayString() string
Equals(task Task) bool
}
Task is the main interface to task definitions
func NewTask ¶
func NewTask() Task
NewTask creates a new TaskData structure and returns a Task interface to it
func NewTaskWithData ¶
NewTaskWithData returns a new Task interfaced based on the supplied TaskData struct
type TaskData ¶
type TaskData struct {
XMLName xml.Name `gorm:"-" xml:"Task"`
gorm.Model `json:"-" xml:"-" csv:"-"`
// Synopsis is a short title or identifier of the task
Synopsis string `gorm:"uniqueindex" json:"Synopsis" xml:"Synopsis" csv:"synopsis"`
// Description is a longer description of the task
Description string `json:"Description" xml:"Description" csv:"description"`
// contains filtered or unexported fields
}
TaskData is the main Task data structure
func NewTaskData ¶
func NewTaskData() TaskData
func (*TaskData) Clear ¶
func (td *TaskData) Clear()
Clear resets the state of this object to the default, newly-initialized state
func (*TaskData) DisplayString ¶
DisplayString returns a string form of the Task suitable for display
func (*TaskData) FindTaskBySynopsis ¶
FindTaskBySynopsis returns a task with a matching synopsis from a slice of tasks
func (*TaskData) LoadAll ¶
LoadAll loads all tasks in the database, optionally including deleted tasks
func (*TaskData) Resolve ¶
Resolve takes a string argument and produces either a taskid (uint) or a synopsis (string)
func (*TaskData) SearchBySynopsis ¶
SearchBySynopsis searches for a task by synopsis only using SQL equals
func (*TaskData) StopRunningTask ¶
func (td *TaskData) StopRunningTask() (timesheetData *TimesheetData, err error)
StopRunningTask stops the currently running task, if any
type TaskDatas ¶
type TaskDatas []TaskData
TaskDatas is a helper type for a slice of TaskData structs
func (TaskDatas) AsTaskList ¶
AsTaskList returns the slice of TaskData structs as a slice of Task interfaces
type TaskList ¶
type TaskList []Task
TaskList represents a slice of tasks
func TaskListFromSliceIntf ¶
func TaskListFromSliceIntf(taskListIntf []interface{}) TaskList
TaskListFromSliceIntf converts a slice of interface{} into a slice of tasks (TaskList). Elements that are not TaskList are excluded from the result.
func (TaskList) Index ¶
Index returns the index of the specified Task in the list or -1 if the Task is not found
func (TaskList) ToSliceIntf ¶
func (tl TaskList) ToSliceIntf() []interface{}
ToSliceIntf converts the slice of tasks into a slice of interface{}
type TaskReport ¶
type TaskReport []TaskReportData
TaskReport is a type alias for a slice of TaskReportData structs
func (TaskReport) Clone ¶
func (tr TaskReport) Clone() TaskReport
type TaskReportData ¶
type TaskReportData struct {
XMLName xml.Name `csv:"-" json:"-" xml:"Report" gorm:"-"`
StartDate sql.NullTime `csv:"started_on,omitempty" json:"started_on,omitempty" xml:"StartedOn,omitempty"`
TaskSynopsis string `csv:"synopsis" json:"synopsis" xml:"Synopsis"`
TaskDescription string `csv:"description,omitempty" json:"description,omitempty" xml:"Description,omitempty"`
TaskID uint `csv:"task_id" json:"task_id" xml:"TaskID"`
DurationSeconds int `csv:"duration" json:"duration" xml:"Duration"`
}
TaskReportData is a struct that contains a single entry of a Task Report
func NewTaskReportData ¶
func NewTaskReportData() *TaskReportData
NewTaskReportData returns a pointer to a new instance of the TaskReportData struct
func (*TaskReportData) Clone ¶
func (trd *TaskReportData) Clone() TaskReportData
Clone returns a copy of this object
func (*TaskReportData) Duration ¶
func (trd *TaskReportData) Duration() time.Duration
Duration returns the DurationSeconds property as a time.Duration
func (*TaskReportData) String ¶
func (trd *TaskReportData) String() string
String implements fmt.Stringer
type Timesheet ¶
type Timesheet interface {
fmt.Stringer
schema.Tabler
Data() *TimesheetData
Create() error
Load() error
Update() error
Delete() error
LoadAll(withDeleted bool) ([]TimesheetData, error)
CountOpen() (int, error)
SearchOpen() ([]TimesheetData, error)
SearchDateRange(withDeleted bool) ([]TimesheetData, error)
LastStartedTasks(limit uint) (startedTasks []TaskData, err error)
TaskReport(startDate, endDate time.Time, withDeleted bool) (reportData TaskReport, err error)
RunningTimesheet() (Timesheet, error)
Equals(other Timesheet) bool
}
Timesheet is the main timesheet function interface
func NewTimesheet ¶
func NewTimesheet() Timesheet
NewTimesheet returns a newly-initialized Timesheet interface
func NewTimesheetWithData ¶
func NewTimesheetWithData(data TimesheetData) Timesheet
NewTimesheetWithData returns a new Timesheet interface based on the supplied TimesheetData struct
type TimesheetData ¶
type TimesheetData struct {
XMLName xml.Name `gorm:"-" xml:"Timesheet" json:"-" csv:"-"`
// Task is the task object linked to this Timesheet
Task TaskData `json:"Task" xml:"Task" csv:"-"`
// StartTime is the time that the task was started at
StartTime time.Time `gorm:"not null;index:idx_timesheet_laststarted,sort:desc" json:"StartTime" xml:"StartTime" csv:"start_time"`
gorm.Model `json:"-" xml:"-" csv:"-"`
// StopTime is the time that the task was stopped at; if it is NULL, that means the task is still running
StopTime sql.NullTime `gorm:"uniqueIndex:idx_timesheet_stoptime" json:"StopTime,omitempty" xml:"StopTime,omitempty" csv:"stop_time,omitempty"`
// TaskID is the database ID of the linked task object
TaskID uint `gorm:"index:idx_timesheet_laststarted" json:"TaskID" xml:"TaskID" csv:"task_id"`
// contains filtered or unexported fields
}
TimesheetData is the main timesheet data structure
func NewTimesheetData ¶
func NewTimesheetData() TimesheetData
NewTimesheetData returns a newly-initialized TimesheetData struct
func (*TimesheetData) CountOpen ¶
func (tsd *TimesheetData) CountOpen() (int, error)
CountOpen returns the count of open timesheets; there should be only one
func (*TimesheetData) Create ¶
func (tsd *TimesheetData) Create() error
Create creates a new timesheet record
func (*TimesheetData) Data ¶
func (tsd *TimesheetData) Data() *TimesheetData
Data returns the struct underlying the interface
func (*TimesheetData) Delete ¶
func (tsd *TimesheetData) Delete() error
Delete marks a timesheet as deleted
func (*TimesheetData) Equals ¶
func (tsd *TimesheetData) Equals(other Timesheet) bool
Equals determines if the specified Timesheet is equal to this one by comparing data.
func (*TimesheetData) LastStartedTasks ¶
func (tsd *TimesheetData) LastStartedTasks(limit uint) (startedTasks []TaskData, err error)
LastStartedTasks returns a list of most-recently started tasks. The size of the list is limited by the limit parameter. If a limit of zero is specified, the default value is used.
func (*TimesheetData) Load ¶
func (tsd *TimesheetData) Load() error
Load attempts to load a timesheet by ID
func (*TimesheetData) LoadAll ¶
func (tsd *TimesheetData) LoadAll(withDeleted bool) ([]TimesheetData, error)
LoadAll loads all timesheet records, optionally including deleted timesheets
func (*TimesheetData) RunningTimesheet ¶
func (tsd *TimesheetData) RunningTimesheet() (Timesheet, error)
RunningTimesheet returns the currently open timesheet. If no timesheet is open then ErrNoRunningTask is returned. If more than 1 timesheet is open, an error is returned.
func (*TimesheetData) SearchDateRange ¶
func (tsd *TimesheetData) SearchDateRange(withDeleted bool) ([]TimesheetData, error)
SearchDateRange returns the timesheets that start on or after the StartTime and end on or before the StopTime
func (*TimesheetData) SearchOpen ¶
func (tsd *TimesheetData) SearchOpen() ([]TimesheetData, error)
SearchOpen returns all open timesheets; there should be only one
func (*TimesheetData) String ¶
func (tsd *TimesheetData) String() string
String implements fmt.Stringer
func (*TimesheetData) TableName ¶
func (tsd *TimesheetData) TableName() string
TableName implements schema.Tabler
func (*TimesheetData) TaskReport ¶
func (tsd *TimesheetData) TaskReport(startDate, endDate time.Time, withDeleted bool) (reportData TaskReport, err error)
TaskReport returns a list of tasks and their aggregated durations between the two supplied dates
func (*TimesheetData) Update ¶
func (tsd *TimesheetData) Update() error
Update attempts to update the timesheet record in the database