models

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Overview

Package models defines the core data structures used throughout timetraced. It includes types representing users, projects, and records, along with supporting types such as report requests. These structs form the shared domain model for persistence, business logic, and presentation layers, and are serialized for storage and communication between packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FmtDuration

func FmtDuration(d time.Duration) string

FmtDuration returns a human readable representation of a duration in hours:minute and decimal hours format.

func IsTrackingActive

func IsTrackingActive(u string) bool

IsTrackingActive checks if tracking has been activated for given user.

func Tracked

func Tracked(u string) string

Tracked returns the poject being tracked for user.

func TrackingActive

func TrackingActive(u string, p Project)

TrackingActive activates tracking for given user and project.

func TrackingInactive

func TrackingInactive(u string)

TrackingInactive deactivates tracking for given user.

func Version added in v0.2.2

func Version()

Version reads version info from executable.

Types

type Config

type Config struct {
	Theme   string `form:"theme"   json:"theme"`
	Font    string `form:"font"    json:"font"`
	Refresh int    `form:"refresh" json:"refresh"`
}

Config represents the user selectable UI options.

type DatabaseReportRequest

type DatabaseReportRequest struct {
	Start   time.Time
	End     time.Time
	Project string
	User    string
}

DatabaseReportRequest represents a ReportRequest formatted for db queries.

type Duration

type Duration struct {
	Project string
	Elapsed string
}

Duration reprents the time spend on a project.

type EditRecord

type EditRecord struct {
	ID        string
	Start     string
	StartTime string
	End       string
	EndTime   string
}

EditRecord represents a time record for editing in UI.

type Editor added in v0.2.0

type Editor struct {
	User

	AsAdmin bool
}

Editor represents the an editor of a user.

type Page

type Page struct {
	Version     string
	Tracking    bool
	Projects    []string
	Status      StatusResponse
	DefaultDate string
}

Page represents the data to for display to user.

func GetPage

func GetPage() Page

GetPage returns default page data.

type Project

type Project struct {
	ID      uuid.UUID
	Name    string
	Active  bool
	Updated time.Time
}

Project represents a project.

type Record

type Record struct {
	ID      uuid.UUID
	Project string
	User    string
	Start   time.Time
	End     time.Time
}

Record represents a time record.

func (*Record) Duration

func (r *Record) Duration() time.Duration

Duration returns the elapsed time from a time record.

type Report

type Report struct {
	Project string
	Total   string
	Items   []ReportRecord
}

Report represents the time spent on a project. It is a response to a ReportRequest.

type ReportRecord

type ReportRecord struct {
	ID    uuid.UUID
	Start time.Time
	End   time.Time
}

ReportRecord represents and individual report record.

type ReportRequest

type ReportRequest struct {
	Start   string `form:"start"   json:"start"`
	End     string `form:"end"     json:"end"`
	Project string `form:"project" json:"project"`
}

ReportRequest contains data to initiate a report.

type StartRequest

type StartRequest struct {
	Project string
}

StartRequest is a request to start recording time for a given project.

type Status

type Status struct {
	Current    string
	Elapsed    time.Duration
	Total      time.Duration
	DailyTotal time.Duration
}

Status represents the time recorded today.

type StatusResponse

type StatusResponse struct {
	Current      string
	Elapsed      string
	CurrentTotal string
	DailyTotal   string
	Durations    []Duration
}

StatusResponse provides a status for display.

type User

type User struct {
	Username string `form:"username" json:"username"`
	Password string `form:"password" json:"password"`
	IsAdmin  bool
	Updated  time.Time
}

User represents a user.

Jump to

Keyboard shortcuts

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