report

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package report aggregates time entries and renders them in various output formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomerProject

type CustomerProject struct {
	Customer timeentry.Customer
	Project  timeentry.Project
}

CustomerProject represents a unique customer/project combination

type RateTotal

type RateTotal struct {
	Rate  float64
	Total float64
}

RateTotal contains the hourly rate and total amount for a customer/project

type Report

type Report struct {
	StartDate types.Date
	EndDate   types.Date
	Config    *config.Config

	// Aggregated data: Customer/Project -> TaskID -> Description -> []*TimeEntry
	AggregatedTime map[CustomerProject]map[timeentry.TaskID]map[string][]*timeentry.TimeEntry
	DayStats       map[types.Date]time.Duration
	RateTotals     map[CustomerProject]RateTotal

	// Filter options
	Customer timeentry.Customer
	Project  timeentry.Project

	// Display options
	Sort             Sort
	Reverse          bool
	TaskGrain        bool
	DescriptionGrain bool

	// Cache for resolving work item metadata (formatted ID, link, description).
	Cache *resolver.ItemDetailCache
	// contains filtered or unexported fields
}

Report holds aggregated time entry data and statistics

func New

func New(ctx context.Context, config *config.Config, start, end types.Date, customer timeentry.Customer, project timeentry.Project, sort Sort, reverse, taskGrain, descriptionGrain bool) (*Report, error)

New creates a new Report by aggregating time entries over the date range

func (*Report) CalculateStatistics

func (r *Report) CalculateStatistics() *Statistics

CalculateStatistics computes statistics from day stats

func (*Report) GenerateHTMLReport

func (r *Report) GenerateHTMLReport(w io.Writer)

GenerateHTMLReport generates an HTML report by converting markdown to HTML

func (*Report) GenerateMarkdownReport

func (r *Report) GenerateMarkdownReport(w io.Writer)

GenerateMarkdownReport generates a markdown-formatted report

func (*Report) GeneratePDFReport

func (r *Report) GeneratePDFReport(outputPath string) error

GeneratePDFReport generates a PDF report by compiling Typst to PDF

func (*Report) GenerateTextReport

func (r *Report) GenerateTextReport() string

GenerateTextReport generates a plain text report matching Python's output format

func (*Report) GenerateTypstReport

func (r *Report) GenerateTypstReport(w io.Writer)

GenerateTypstReport generates a Typst-formatted report

type Sort

type Sort int

Sort represents how to sort report entries

const (
	SortAlphabetical Sort = iota
	SortTimeSpent
)

type Statistics

type Statistics struct {
	DaysWorked        int
	WeekdaysWorked    int
	WeeksWorked       float64
	AvgTimePerDay     time.Duration
	AvgTimePerWeekday time.Duration
	AvgTimePerWeek    time.Duration
}

Statistics holds calculated statistics for a report period

Jump to

Keyboard shortcuts

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