Expand description
Productivity stats tracking for task completions, streaks, and velocity metrics.
Responsibilities:
- Track daily task completions and calculate streaks
- Record milestone achievements (10, 50, 100, etc.)
- Calculate velocity metrics (tasks per day/week)
- Persist stats to
.ralph/cache/productivity.jsonc
Not handled here:
- Queue/task management (see
crate::queue) - Notification delivery (see
crate::notification) - Celebration rendering (see
crate::celebrations)
Invariants/assumptions:
- Stats file is JSON with schema version for migrations
- Timestamps are RFC3339 format
- All operations are atomic (read-modify-write with file locking)
Structs§
- Completed
Task Ref - Reference to a completed task
- Completion
Result - Result of recording a task completion
- DayStats
- Stats for a single day
- Estimation
Metrics - Estimation accuracy metrics for tasks with both estimated and actual minutes.
- Milestone
- A milestone achievement
- Productivity
Estimation Report - Productivity estimation report
- Productivity
Stats - Root productivity data structure
- Productivity
Streak Report - Productivity streak report
- Productivity
Summary Report - Productivity summary report
- Productivity
Velocity Report - Productivity velocity report
- Session
Summary - Session summary for display after run loop
- Streak
Info - Streak tracking information
- Task
Estimation Point - Single task estimation data point.
- Velocity
Metrics - Velocity metrics for a given time period
Functions§
- build_
estimation_ report - Build an estimation report from tasks
- build_
streak_ report - Build a streak report
- build_
summary_ report - Build a summary report
- build_
velocity_ report - Build a velocity report
- calculate_
estimation_ metrics - Calculate estimation accuracy metrics from completed tasks. Only includes tasks that have both estimated_minutes and actual_minutes set.
- calculate_
velocity - Calculate velocity metrics for the given number of days.
- date_
key_ add_ days - Return
date_keyoffset bydelta_days. - format_
date_ key - Format a
time::Dateas a date key (YYYY-MM-DD). - format_
duration - Format a duration in seconds to a human-readable string
- load_
productivity_ stats - Load productivity stats from cache directory
- mark_
milestone_ celebrated - Mark a milestone as celebrated
- next_
milestone - Get the next milestone threshold
- parse_
date_ key - Parse a date key (YYYY-MM-DD) into a
time::Date. - previous_
date_ key - Return the previous day’s date key.
- print_
estimation_ report_ text - Print estimation report in text format
- print_
streak_ report_ text - Print streak report in text format
- print_
summary_ report_ text - Print summary report in text format
- print_
velocity_ report_ text - Print velocity report in text format
- record_
task_ completion - Record a task completion and update stats
- record_
task_ completion_ by_ id - Record a task completion by ID and title (for cases where Task isn’t available)
- save_
productivity_ stats - Save productivity stats to cache directory
- update_
streak - Update streak based on completion date