core

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Human   = "h"
	Seconds = "s"
	Minutes = "m"
	Hours   = "r"
)

Variables

This section is empty.

Functions

func AllowedPeriodFixedTimeFrames

func AllowedPeriodFixedTimeFrames() []string

AllowedPeriodFixedTimeFrames returns an array of allowed period fixed time frames

Types

type Activity

type Activity struct {
	Name        string `json:"name""`
	Alias       string `json:"alias""`
	Description string `json:"description"`
	Id          int    `json:"id"`
}

Activity represents an activity done by the user is some point in time

func (*Activity) HasAlias

func (activity *Activity) HasAlias() bool

HasAlias returns true if the activity has an alias defined on it

func (*Activity) HasDescription

func (activity *Activity) HasDescription() bool

HasDescription returns true if the activity has a description

func (*Activity) ToPrintableString

func (activity *Activity) ToPrintableString() string

ToPrintableString returns a pretty string with the activity data

func (*Activity) ValidateName

func (activity *Activity) ValidateName() error

ValidateName validates the correctness of the activity name.

type ActivityDurationDayAggregation

type ActivityDurationDayAggregation struct {
	Activity Activity
	Date     string
	Duration int
}

ActivityDurationDayAggregation represents the total duration of an activity for a given date.

type ActivityLog

type ActivityLog struct {
	Id        int
	Date      string
	StartedAt *time.Time
	StoppedAt *time.Time
	Activity  Activity
}

ActivityLog represents one run of an activity in a given point in time

type ActivityRepository

type ActivityRepository interface {
	Initialize(config.Config) error
	Shutdown() error
	Add(Activity) error
	Delete(string) error
	List() ([]Activity, error)
	Update(string, UpdateActivity) error
	Find(string) (*Activity, error)
	Start(Activity) error
	LogsForPeriod(Period) (map[string][]ActivityDurationDayAggregation, error)
	Stop(Activity) error
	CurrentlyTrackedActivity() (*Activity, error)
	WipeLogsPeriodAndActivity(Period, *Activity) error
	WipeLogsPeriod(Period) error
}

ActivityRepository is the generic interface that exposes methods to create and read activities from a store.

type DurationFormat

type DurationFormat interface {
	Format(int) string
}

DurationFormat is a generic interface to represent activity durations

func ParseDurationFormat

func ParseDurationFormat(f string) DurationFormat

type HoursDurationFormat

type HoursDurationFormat struct{}

func (HoursDurationFormat) Format

func (f HoursDurationFormat) Format(secondsDuration int) string

type HumanDurationFormat

type HumanDurationFormat struct{}

func (HumanDurationFormat) Format

func (f HumanDurationFormat) Format(secondsDuration int) string

type MinutesDurationFormat

type MinutesDurationFormat struct{}

func (MinutesDurationFormat) Format

func (f MinutesDurationFormat) Format(secondsDuration int) string

type NoActivityUpdate

type NoActivityUpdate struct{}

func (NoActivityUpdate) Visit

func (upd NoActivityUpdate) Visit(act *Activity)

type Period

type Period struct {
	Sd time.Time
	Ed time.Time
}

Period represents a time period

func PeriodFromDateStrings

func PeriodFromDateStrings(sd, ed string) (Period, error)

PeriodFromDateStrings returns a new period struct from two date strings, if they are valid

func PeriodFromKeyWord

func PeriodFromKeyWord(keyword string) Period

PeriodFromKeyWord returns a fixed period from a representation string, relative to the current date.

func (*Period) EndDateDay

func (period *Period) EndDateDay() string

func (*Period) ForEachDay

func (period *Period) ForEachDay(fn func(time.Time) error)

func (*Period) NumberOfDays

func (period *Period) NumberOfDays() int

NumberOfDays returns the number of days in the period

func (*Period) StartDateDay

func (period *Period) StartDateDay() string

type Reporter

type Reporter interface {
	Initialize(ActivityRepository, Period) error
	ProduceReport() error
	SetDurationFormat(DurationFormat)
}

Reporter is an object responsible for producing activities reports

type SecondsDurationFormat

type SecondsDurationFormat struct{}

func (SecondsDurationFormat) Format

func (f SecondsDurationFormat) Format(secondsDuration int) string

type UpdateActivity

type UpdateActivity interface {
	Visit(*Activity)
}

type UpdateActivityDescription

type UpdateActivityDescription struct {
	Desc string
}

func (UpdateActivityDescription) Visit

func (upd UpdateActivityDescription) Visit(act *Activity)

type UpdateActivityName

type UpdateActivityName struct {
	Name string
}

func (UpdateActivityName) Visit

func (upd UpdateActivityName) Visit(act *Activity)

type UpdateActivityNameAndDescription

type UpdateActivityNameAndDescription struct {
	Name string
	Desc string
}

func (UpdateActivityNameAndDescription) Visit

Jump to

Keyboard shortcuts

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