Documentation
¶
Index ¶
- Constants
- func AllowedPeriodFixedTimeFrames() []string
- type Activity
- type ActivityDurationDayAggregation
- type ActivityLog
- type ActivityRepository
- type DurationFormat
- type HoursDurationFormat
- type HumanDurationFormat
- type MinutesDurationFormat
- type NoActivityUpdate
- type Period
- type Reporter
- type SecondsDurationFormat
- type UpdateActivity
- type UpdateActivityDescription
- type UpdateActivityName
- type UpdateActivityNameAndDescription
Constants ¶
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) HasDescription ¶
HasDescription returns true if the activity has a description
func (*Activity) ToPrintableString ¶
ToPrintableString returns a pretty string with the activity data
func (*Activity) ValidateName ¶
ValidateName validates the correctness of the activity name.
type ActivityDurationDayAggregation ¶
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 ¶
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 ¶
Period represents a time period
func PeriodFromDateStrings ¶
PeriodFromDateStrings returns a new period struct from two date strings, if they are valid
func PeriodFromKeyWord ¶
PeriodFromKeyWord returns a fixed period from a representation string, relative to the current date.
func (*Period) EndDateDay ¶
func (*Period) NumberOfDays ¶
NumberOfDays returns the number of days in the period
func (*Period) StartDateDay ¶
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 ¶
func (UpdateActivityNameAndDescription) Visit ¶
func (upd UpdateActivityNameAndDescription) Visit(act *Activity)