fix(stats): correct hourly bucket timezone parsing in stats module - #217
Merged
devJaja merged 1 commit intoJul 30, 2026
Merged
Conversation
SQLite's strftime() returns naive datetime strings ("YYYY-MM-DD HH:00:00")
with no timezone marker, but the values are computed in UTC since
createdAt is stored as UTC ISO strings. JS's `new Date(...)` parses that
space-separated, zone-less format as local time, so on any host not
running in UTC the hourly bucket keys drift and fail to match the
UTC-based series timestamps, leaving tasksLast24h/xlmLast24h values at 0.
Append a literal "Z" to the strftime format so the returned string is a
valid UTC ISO8601 string that Date parses correctly regardless of the
host timezone.
Closes Epta-Node#164
|
@codeX-james is attempting to deploy a commit to the Jaja's projects Team on Vercel. A member of the Team first needs to authorize it. |
devJaja
self-requested a review
July 30, 2026 04:37
Contributor
|
Solid Implementation @JamesVictor-O I can see All CI checks Passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #164.
The stats module's SQL (
?placeholders,strftime,status = 'completed') had already been converted to SQLite syntax in a prior fix for the duplicate issue #175, butbackend/src/db/stats.test.tswas still failing:Root cause:
strftime('%Y-%m-%d %H:00:00', "createdAt")returns a naive, space-separated datetime string with no timezone marker (e.g."2026-06-16 13:00:00"). SincecreatedAtis stored as UTC ISO strings, this value represents UTC time — butnew Date("2026-06-16 13:00:00")in JS parses zone-less, space-separated strings as local time, not UTC. On any host not running in the UTC timezone, the hourly bucket keys drift by the host's UTC offset and no longer match the UTC-based series timestamps built inbuildHourlySeries, sotasksLast24h/xlmLast24hvalues silently come back as0.Fix
Append a literal
Zto thestrftimeformat string ingetTasksHourlyCountsandgetXLMHourlyTotals(backend/src/db/stats.ts), so SQLite returns a valid UTC ISO8601 string (e.g."2026-06-16 13:00:00Z") thatDateparses correctly regardless of host timezone.Test plan
npx jest src/db/stats.test.ts— both tests pass (previously 1 failing)npx jest --runInBand --forceExit— full backend suite passes (251 passed, 2 skipped, unrelated)npx tsc -p tsconfig.json --noEmit— no type errors