feat(dashboard): traffic-aware latest values for cw_traffic2 - #80
Merged
Merged
Conversation
…traffic2 cw_traffic2 is an hourly accumulator: one row per (dev_eui, traffic_hour, line_number), upserted by an increment RPC that never bumps created_at, so ORDER BY created_at DESC LIMIT 1 returned an arbitrary line's freshly created (near-empty) bucket — dashboard cards showed zeros. - fetchLatest/getLatest now branch for cw_traffic2: sum every count column across all of today's hour buckets and detection lines (local day in Asia/Tokyo, matching TrafficService's default); getLatest returns an aggregated pseudo-row (no id/line_number) with the latest traffic_hour - Zero rows today reports zero totals with the freshness stamp of the most recent bucket (a quiet day is legitimately 0, not "no data") - Move localMidnightToUtc/toLocalDateString/getTimezoneOffsetMs from TrafficService into TimezoneFormatterService for reuse; DashboardModule imports CommonModule Other tables keep the existing latest-row path — backward compatible. Deploy before the frontend traffic redesign (frontend-first leaves dashboard zeros until this ships). Co-Authored-By: Claude Fable 5 <[email protected]>
CropWatchDevelopment
temporarily deployed
to
Production
July 27, 2026 09:36 — with
GitHub Actions
Inactive
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Dashboard cards for AI-camera (cw_traffic2) devices showed all zeros: the table is an hourly accumulator — one row per (dev_eui, traffic_hour, line_number) upserted by an increment RPC that never bumps created_at — so
ORDER BY created_at DESC LIMIT 1returned an arbitrary line's freshly created, near-empty bucket.fetchLatest/getLatestnow branch for cw_traffic2 and return today's totals per count column, summed across all hour buckets and detection lines (local day in Asia/Tokyo, matching TrafficService)getLatestreturns an aggregated pseudo-row (noid/line_number) with the latesttraffic_hourTimezoneFormatterServicefor reuseDeploy this before the frontend traffic redesign (CropWatch PR) — frontend-first leaves the dashboard zeros in place until this ships.
🤖 Generated with Claude Code