timetracker/.ai/features/reports.md
2026-08-03 21:51:48 +02:00

52 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Feature: Reports
## Views
| View | Period | Grouping |
|---------|---------------|-----------------------|
| Daily | Selected day | Per entry (list) |
| Weekly | MonSun | Per day (bar chart) |
| Monthly | Calendar month| Per week (bar chart) |
## Chart Data Format (fl_chart BarChart)
```dart
// Weekly: 7 bars (Mon=0 … Sun=6)
List<BarChartGroupData> weeklyBars(Map<int, Duration> durationByWeekday) {
return List.generate(7, (i) => BarChartGroupData(
x: i,
barRods: [BarChartRodData(toY: durationByWeekday[i]?.inMinutes.toDouble() ?? 0)],
));
}
```
## Key Queries (Drift)
```dart
// Total duration per project in date range
SELECT project_id, SUM(duration_s) AS total
FROM time_entries
WHERE start_time >= :from AND start_time < :to
AND end_time IS NOT NULL
GROUP BY project_id;
// Duration per weekday in week
SELECT strftime('%w', start_time) AS weekday, SUM(duration_s) AS total
FROM time_entries
WHERE start_time >= :weekStart AND start_time < :weekEnd
AND end_time IS NOT NULL
GROUP BY weekday;
```
## ReportsNotifier
- Exposes `selectedPeriod` (day/week/month) and `selectedDate`
- Provides `AsyncValue<ReportData>` via Drift watch stream
- `ReportData` contains: total duration, per-project breakdown, chart bars
## Filters
- Filter by project (optional, default: all projects)
- Filter by tag (optional)
- Date navigation: previous/next period buttons
## Summary Cards
Each report view shows:
- Total tracked time for period
- Most tracked project
- Average daily hours (weekly/monthly view)