models

package
v0.3.1-alpha5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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)
	StopRunningTask() (*TimesheetData, error)
	FindTaskBySynopsis(tasks []TaskData, synopsis string) *TaskData
	Resolve(arg string) (uint, string)
}

Task is the main interface to task definitions

func NewTask added in v0.3.1

func NewTask() Task

NewTask creates a new TaskData structure and returns a Task interface to it

func NewTaskWithData added in v0.3.1

func NewTaskWithData(data TaskData) Task

NewTaskWithData returns a new Task interfaced based on the supplied TaskData struct

type TaskData

type TaskData struct {
	gorm.Model
	// Synopsis is a short title or identifier of the task
	Synopsis string `gorm:"uniqueindex"`
	// Description is a longer description of the task
	Description string
	// contains filtered or unexported fields
}

TaskData is the main Task data structure

func (*TaskData) Clear

func (td *TaskData) Clear()

Clear resets the state of this object to the default, newly-initialized state

func (*TaskData) Clone

func (td *TaskData) Clone() Task

Clone creates a clone of this TaskData object and returns the clone

func (*TaskData) Create

func (td *TaskData) Create() error

Create creates a new task

func (*TaskData) Data added in v0.3.1

func (td *TaskData) Data() *TaskData

Data returns the underlying struct of the interface

func (*TaskData) Delete

func (td *TaskData) Delete() error

Delete marks the task as deleted

func (*TaskData) FindTaskBySynopsis

func (td *TaskData) FindTaskBySynopsis(tasks []TaskData, synopsis string) *TaskData

FindTaskBySynopsis returns a task with a matching synopsis from a slice of tasks

func (*TaskData) Load

func (td *TaskData) Load(withDeleted bool) error

Load attempts to load the task specified by ID or Synopsis

func (*TaskData) LoadAll

func (td *TaskData) LoadAll(withDeleted bool) ([]TaskData, error)

LoadAll loads all tasks in the database, optionally including deleted tasks

func (*TaskData) Resolve

func (td *TaskData) Resolve(arg string) (taskid uint, tasksynopsis string)

Resolve takes a string argument and produces either a taskid (uint) or a synopsis (string)

func (*TaskData) Search

func (td *TaskData) Search(text string) ([]TaskData, error)

Search searches for a task by synopsis or description using SQL LIKE

func (*TaskData) StopRunningTask

func (td *TaskData) StopRunningTask() (timesheetData *TimesheetData, err error)

StopRunningTask stops the currently running task, if any

func (*TaskData) String

func (td *TaskData) String() string

String implements fmt.Stringer

func (*TaskData) TableName

func (td *TaskData) TableName() string

TableName implements schema.Tabler

func (*TaskData) Update

func (td *TaskData) Update(withDeleted bool) error

Update writes task changes to the database

type TaskReport added in v0.3.1

type TaskReport []TaskReportData

TaskReport is a type alias for a slice of TaskReportData structs

func (TaskReport) Clone added in v0.3.1

func (tr TaskReport) Clone() TaskReport

type TaskReportData added in v0.3.1

type TaskReportData struct {
	TaskID          uint
	TaskSynopsis    string
	TaskDescription string
	StartDate       sql.NullTime
	DurationSeconds int
}

TaskReportData is a struct that contains a single entry of a Task Report

func NewTaskReportData added in v0.3.1

func NewTaskReportData() *TaskReportData

NewTaskReportData returns a pointer to a new instance of the TaskReportData struct

func (*TaskReportData) Clone added in v0.3.1

func (trd *TaskReportData) Clone() TaskReportData

Clone returns a copy of this object

func (*TaskReportData) Duration added in v0.3.1

func (trd *TaskReportData) Duration() time.Duration

Duration returns the DurationSeconds property as a time.Duration

func (*TaskReportData) String added in v0.3.1

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)
	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)
}

Timesheet is the main timesheet function interface

func NewTimesheet added in v0.3.1

func NewTimesheet() Timesheet

NewTimesheet returns an new, initialized Timesheet interface

func NewTimesheetWithData added in v0.3.1

func NewTimesheetWithData(data TimesheetData) Timesheet

NewTimesheetWithData returns a new Timesheet interface based on the supplied TimesheetData struct

type TimesheetData

type TimesheetData struct {
	gorm.Model
	// Task is the task object linked to this Timesheet
	Task TaskData
	// TaskID is the database ID of the linked task object
	TaskID uint
	// StartTime is the time that the task was started at
	StartTime time.Time `gorm:"not null"`
	// StopTime is the time that the task was stopped at; if it is NULL, that means the task is still running
	StopTime sql.NullTime
	// contains filtered or unexported fields
}

TimesheetData is the main timesheet data structure

func (*TimesheetData) Create

func (tsd *TimesheetData) Create() error

Create creates a new timesheet record

func (*TimesheetData) Data added in v0.3.1

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) LastStartedTasks added in v0.3.1

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) 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 added in v0.3.1

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

Jump to

Keyboard shortcuts

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