Skip to content

Count report time per day, not per whole session - #159

Open
wayx112 wants to merge 1 commit into
Team6083:mainfrom
wayx112:fix/report-days
Open

wayx112 wants to merge 1 commit into
Team6083:mainfrom
wayx112:fix/report-days

Conversation

@wayx112

@wayx112 wayx112 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Summary

The daily and user reports put whole sessions on one day, so their numbers could be impossible:

  • Daily report: it took logs whose clock-in or clock-out fell on the day. A session covering the whole day, or still open since an earlier day, was left out. A counted session's full length also went to that day. On a preview, 11/16 showed 2 active users while a member had been in since 11/13, and "Longest duration 65 hr".
  • User report: each session's full length went to the UTC date it started. A day could show "65h", "Avg / Day" could pass 24 hours (157 hr on the preview), and an early-morning session in Taipei landed on the day before.

This PR changes:

  • Daily: takes every session that overlaps the day, including open ones, and counts only the part within the day for the durations. The heatmap already clipped to the day.
  • User: splits each session at midnight in TZ (splitByDay in zoned-time.ts) for the daily breakdown, calendar and "Days attended". With a period selected, only the part inside it counts toward the totals.
  • The session list still shows each session whole.

Evidence

Same preview data, before and after:

daily 11/16      active users 2 -> 3      longest 65 hr 23 min -> 19 hr 28 min (in since 11/13, out 19:28)
user report      Nov 13: 65h 9m -> split over 11/14 23h 14m, 11/15 24h, 11/16 17h 55m
                 Avg / Day 157 hr -> 22 hr
Test Files  25 passed (25)
     Tests  335 passed (335)

New tests for splitByDay: splitting at Taipei midnight, not UTC, and a same-day or empty session. tsc --noEmit, ESLint on the changed files and npm run build pass.

Merge danger

Door: two-way. Report reads only.

Blast radius: /report/daily and /report/user. Past days will show different numbers than before, and the new ones are the right ones; worth saying if anyone compares with old screenshots.

🤖 Generated with Claude Code

The daily report took logs whose clock-in or clock-out fell on the day. A session covering the whole day, or still open since an earlier day, was left out (11/16 showed 2 active users while a member had been in since 11/13), and a counted session's full length went to that day ("Longest duration 65 hr"). It now takes every session that overlaps the day and counts only the part within it.

The user report put each session's full length on the UTC date it started, so a day could show "65h" and "Avg / Day" could pass 24 hours, and early-morning sessions in Taipei landed on the day before. Sessions are now split at midnight in TZ, and with a period selected only the part inside it counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant