stats

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package stats reports Focus session statistics

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregates

type Aggregates struct {
	Weekly  map[string]time.Duration `json:"weekly"`
	Weekday map[string]time.Duration `json:"weekday"`
	Daily   map[string]time.Duration `json:"daily"`
	Yearly  map[string]time.Duration `json:"yearly"`
	Monthly map[string]time.Duration `json:"monthly"`
	Hourly  map[string]time.Duration `json:"hourly"`
	// contains filtered or unexported fields
}

type Opts

type Opts struct {
	config.FilterConfig
}

type Record

type Record struct {
	Name     string        `json:"name"`
	Duration time.Duration `json:"duration"`
}

type Stats

type Stats struct {
	Aggregates      Aggregates        `json:"aggregates"`
	StartTime       time.Time         `json:"start_time"`
	EndTime         time.Time         `json:"end_time"`
	DB              store.DB          `json:"-"`
	Opts            Opts              `json:"-"`
	Sessions        []*models.Session `json:"-"`
	LastDayTimeline []Timeline        `json:"timeline"`
	Summary         Summary           `json:"summary"`
}

Stats represents the computed focus statistics for a period of time.

func (*Stats) Compute

func (s *Stats) Compute(sessions []*models.Session)

Compute calculates Focus statistics for a specific time period.

func (*Stats) Server

func (s *Stats) Server(port uint) error

func (*Stats) ToJSON

func (s *Stats) ToJSON() ([]byte, error)

type Summary

type Summary struct {
	Tags         map[string]time.Duration `json:"-"`
	TotalTime    time.Duration            `json:"total_time"`
	Completed    int                      `json:"completed"`
	Abandoned    int                      `json:"abandoned"`
	AvgCompleted int                      `json:"avg_completed"`
	AvgAbandoned int                      `json:"avg_abandoned"`
	AvgTime      time.Duration            `json:"avg_time"`
}

type TemplateData

type TemplateData struct {
	StartTime string
	EndTime   string
	Stats     string
	MainChart string
	Days      int
}

type Timeline

type Timeline struct {
	StartTime time.Time     `json:"start_time"`
	Tags      []string      `json:"tags"`
	Duration  time.Duration `json:"duration"`
}

Jump to

Keyboard shortcuts

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