base

package
v0.0.0-...-766887c Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimesheetActionStart int = iota + 1
	TimesheetActionStop
)

Variables

This section is empty.

Functions

func FormatSeconds

func FormatSeconds(s int) string

Types

type BranchItem

type BranchItem struct {
	ProjectId  int    `db:"project_id"`
	BranchName string `db:"branch_name"`
	ItemCount  int    `db:"item_count"`
}

type ItemAndBranch

type ItemAndBranch struct {
	ItemName   string `db:"item_name"`
	BranchName string `db:"branch_name"`
}

type Project

type Project struct {
	Id     int    `db:"project_id"`
	Folder string `db:"folder"`
	Branch string `db:"branch"`
	Name   string `db:"name"`
}

type Report

type Report struct {
	From             string
	To               string
	Repos            []*ReportRepo
	TotalTimeSeconds int
}

func (*Report) MarshalJSON

func (r *Report) MarshalJSON() ([]byte, error)

type ReportItem

type ReportItem struct {
	Id        int    `db:"todo_id"`
	ProjectId int    `db:"project_id"`
	Task      string `db:"task"`
	TimeAt    string `db:"time_at"`
}

func (ReportItem) MarshalJSON

func (ri ReportItem) MarshalJSON() ([]byte, error)

type ReportProject

type ReportProject struct {
	Proj             *Project
	CompletedItems   []ReportItem
	CreatedItems     []ReportItem
	TimeEntries      []ReportTimeEntry
	TotalTimeSeconds int
	LatestUpdate     string
	TimerRunning     bool
}

func (*ReportProject) MarshalJSON

func (rp *ReportProject) MarshalJSON() ([]byte, error)

type ReportRepo

type ReportRepo struct {
	Folder           string           `json:"repo"`
	LatestUpdate     string           `json:"-"`
	Projects         []*ReportProject `json:"projects"`
	TotalTimeSeconds int              `json:"total_sec"`
}

type ReportTimeEntry

type ReportTimeEntry struct {
	ProjectId   int    `db:"project_id"`
	From        string `db:"started_at"`
	To          string `db:"stopped_at"`
	DurationSec int    `db:"duration"`
	Running     bool
}

func (ReportTimeEntry) MarshalJSON

func (rte ReportTimeEntry) MarshalJSON() ([]byte, error)

type TimeEntry

type TimeEntry struct {
	Id        int    `db:"timesheet_id"`
	ProjectId int    `db:"project_id"`
	Action    int    `db:"action"`
	CreatedAt string `db:"created_at"`
}

func (*TimeEntry) Duration

func (ts *TimeEntry) Duration() int

Duration returns a duration in seconds of an active timer. If the timer entry is a stop entry, method returns zero.

type TimerError

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

func (*TimerError) Error

func (e *TimerError) Error() string

type TimerRunningElsewhereError

type TimerRunningElsewhereError struct {
	Proj  *Project
	Entry *TimeEntry
}

func (*TimerRunningElsewhereError) Error

type Todo

type Todo struct {
	Id          int            `db:"todo_id"`
	ProjectId   int            `db:"project_id"`
	Task        string         `db:"task"`
	Position    int            `db:"position"`
	CreatedAt   string         `db:"created_at"`
	DoneAt      sql.NullString `db:"done_at"`
	CommittedAt sql.NullString `db:"committed_at"`
}

type TodoDb

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

func NewTodoDb

func NewTodoDb() (*TodoDb, error)

func NewTodoDbSrc

func NewTodoDbSrc(path string) (*TodoDb, error)

func (*TodoDb) AddTodo

func (tdb *TodoDb) AddTodo(projId int, task string) (int, int)

func (*TodoDb) AddTodos

func (tdb *TodoDb) AddTodos(projId int, tasks []string) error

func (*TodoDb) ChangePosition

func (tdb *TodoDb) ChangePosition(todoId, from, to int) error

func (*TodoDb) CheckTimer

func (tdb *TodoDb) CheckTimer(projId int) (*TimeEntry, error)

CheckTimer gets the latest time entry and checks it against the project id

func (*TodoDb) Close

func (db *TodoDb) Close() error

func (*TodoDb) CopyProjectItems

func (tdb *TodoDb) CopyProjectItems(projFrom, projTo int) error

func (*TodoDb) CreateReport

func (tdb *TodoDb) CreateReport(from, to, folderFilter string) (*Report, error)

func (*TodoDb) Delete

func (tdb *TodoDb) Delete(todoId int) error

func (*TodoDb) DeleteProject

func (tdb *TodoDb) DeleteProject(projId int) error

func (*TodoDb) FetchProjectId

func (tdb *TodoDb) FetchProjectId(folder, branch string) int

FetchProjectId gets or creates a project for the given folder and branch and returns the project id

func (*TodoDb) GetBranches

func (tdb *TodoDb) GetBranches(repo string) ([]BranchItem, error)

func (*TodoDb) GetItemsAndBranch

func (tdb *TodoDb) GetItemsAndBranch(ids []int) ([]*ItemAndBranch, error)

func (*TodoDb) GetLatestTimeEntry

func (tdb *TodoDb) GetLatestTimeEntry() *TimeEntry

GetLatestTimeEntry returns the last recorded time entry if found

func (*TodoDb) GetProject

func (tdb *TodoDb) GetProject(projId int) Project

func (*TodoDb) GetProjectTime

func (tdb *TodoDb) GetProjectTime(projId int) (int, error)

GetProjectTime calculates total amount of seconds recorded for the project, including the ongoing time if the timer is active

func (*TodoDb) MoveTodo

func (tdb *TodoDb) MoveTodo(todoId, projId int) error

MoveTodo moves an item to another project and updates positions

func (*TodoDb) SetItemsCommitted

func (tdb *TodoDb) SetItemsCommitted(projId int, previous bool) error

func (*TodoDb) StartTimer

func (tdb *TodoDb) StartTimer(projId int) (*TimeEntry, error)

StartTimer creates a new start entry, errors if already started

func (*TodoDb) StopTimer

func (tdb *TodoDb) StopTimer() (*TimeEntry, *TimeEntry, error)

StopTimer creates a new stop entry and returns both the new and the previous entry. Returns error if the timer is stopped.

func (*TodoDb) TodoCount

func (tdb *TodoDb) TodoCount(projId int) int

func (*TodoDb) TodoDone

func (tdb *TodoDb) TodoDone(todoId int, done bool) error

func (*TodoDb) TodoItems

func (tdb *TodoDb) TodoItems(projId int, f func(t Todo)) error

func (*TodoDb) TodoItemsDone

func (tdb *TodoDb) TodoItemsDone(projId int, f func(t Todo)) error

func (*TodoDb) TodoItemsForCommit

func (tdb *TodoDb) TodoItemsForCommit(projId int, previous bool, f func(t Todo)) error

func (*TodoDb) TodoWhat

func (tdb *TodoDb) TodoWhat(projId int) *Todo

func (*TodoDb) UpdateProjectName

func (tdb *TodoDb) UpdateProjectName(projId int, name string) error

func (*TodoDb) UpdateTask

func (tdb *TodoDb) UpdateTask(todoId int, task string) error

func (*TodoDb) Vacuum

func (tdb *TodoDb) Vacuum() error

Jump to

Keyboard shortcuts

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