Commit 83dc881
authored
feat: add work time report view (#775)
* feat: add work time report view
Add a new Work Report view that provides daily work time breakdowns
with multi-device support, category filtering, configurable break time
(gap merging via flood), and CSV/JSON export.
Based on #742 by @ErikBjare. Changes from original:
- Implemented thisWeek and thisMonth date ranges
- Removed debug console.log statements
- Used safeHost consistently in find_bucket queries
Closes #742
* fix(WorkReport): use original hostname in find_bucket, safeHost only for variable names
Bucket IDs preserve the original hostname (e.g. 'aw-watcher-window_my-laptop'),
but variable names in the query language must be alphanumeric. The sanitized
safeHost is correct for variable naming, but find_bucket must use the original
hostname to locate the bucket.
* fix(WorkReport): fix startOfDay offset and add AFK filtering
Two P1 bugs flagged by Greptile:
1. startOfDay offset was silently ignored — moment().add('04:00') is a
no-op (moment expects (amount, unit) or ISO 8601). Now uses
get_day_start_with_offset/get_day_end_with_offset from util/time,
the same helpers used by every other view.
2. AFK time was counted as work time — the per-host query never
intersected with aw-watcher-afk data. Now applies the standard
not_afk pattern (flood → filter_keyvals status=not-afk →
filter_period_intersect) before categorizing events, matching the
canonicalEvents pattern in src/queries.ts.
* fix(WorkReport): use query_bucket directly and safeHostname from queries.ts
* fix(WorkReport): add empty category guard and fix hostname collision
- Add validation: alert when no categories selected (previously silent all-zeros)
- Use indexed AQL variables (events_0, events_1, ...) instead of
safeHostname() to prevent collisions when hostnames differ only in
non-alphanumeric chars (e.g., 'my-laptop' vs 'mylaptop')
- Remove unused safeHostname import
Addresses Greptile review findings on PR #775.
* fix(work-report): guard hosts without AFK buckets
* test(router): cover work report route and landingpage redirect
* fix(work-report): skip hosts without AFK buckets1 parent c92b8f9 commit 83dc881
7 files changed
Lines changed: 511 additions & 1 deletion
File tree
- src
- components
- util
- views
- test/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| |||
98 | 101 | | |
99 | 102 | | |
100 | 103 | | |
| 104 | + | |
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
0 commit comments