Skip to content

fix(dashboards): use date for charted time fields so time-series render - #67

Merged
os-zhuang merged 1 commit into
mainfrom
fix/timeseries-charts-datetime
Jun 18, 2026
Merged

os-zhuang merged 1 commit into
mainfrom
fix/timeseries-charts-datetime

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Several dashboards' time-series charts and "last N months/days" KPIs silently rendered "No rows" even though the data existed.

Root cause (platform-level)

The analytics dataset executor binds dashboard date tokens ({12_months_ago}, {90_days_ago}, {today}, …) as ISO date strings ("2025-06-18").

  • A Field.date column stores ISO text → col >= '2025-06-18' matches. ✅
  • A Field.datetime column stores an integer epoch (1780012800000). In SQLite an INTEGER always sorts before any TEXT, so epoch >= 'YYYY-MM-DD' is always false → empty result. ❌

The un-filtered cube returns the rows (which is why the data looked present). Confirmed by diffing the working evidence KPI (expires_on = date → text storage) against the broken assessments chart (assessed_at = datetime → epoch storage), and by direct SQLite queries:

WHERE assessed_at >= '2025-06-18'   → 0 rows   (datetime/epoch column)
WHERE expires_on  >= '2026-06-18'   → 2 rows   (date/text column)

Template fix

Change the charted / date-token-filtered timestamp fields from datetime → date (day granularity is all these reports need; the column then stores ISO text the analytics layer compares correctly):

field chart
compliance_assessment.assessed_at Assessments by Month
todo_task.completed_at Throughput by Week
expense_report.reimbursed_at Spend by Month
content_piece.published_at Published by Month
content_publication.published_at ROI dashboard (90-day KPIs + charts)

Deliberately not changed: helpdesk_ticket.resolved_at stays datetime — SLA-resolution timing needs sub-day precision (flows compare it, breach logic uses it). Its "Resolutions by Day" chart stays empty until the platform binds epoch for datetime columns. The full gotcha is documented in AGENTS.md for future template authors.

Verification

  • Fresh boot stores all five fields as ISO text (typeof = text).
  • Chart SQL (status IN (...) AND assessed_at >= '2025-06-18') goes 0 → 4 rows.
  • Browser: the compliance "按月完成的评估(近 12 个月)" chart now renders a line (y-axis populated) where it previously showed "No rows".

🤖 Generated with Claude Code

…nder

Time-series charts (and "last N months/days" KPIs) silently rendered
"No rows" on several dashboards even though the data existed.

Root cause (platform): the analytics dataset executor binds dashboard date
tokens (`{12_months_ago}`, `{90_days_ago}`, `{today}`, …) as ISO date
**strings** ("2025-06-18"). A `Field.date` column stores ISO text, so
`col >= '2025-06-18'` matches; a `Field.datetime` column stores an **integer
epoch** (1780012800000), and in SQLite an INTEGER always sorts before any
TEXT, so `epoch >= 'YYYY-MM-DD'` is ALWAYS FALSE → empty chart. (The
un-filtered cube returns the rows, which is why the data looked present.)
Confirmed by diffing the working evidence KPI (`expires_on` = date → text)
against the broken assessments chart (`assessed_at` = datetime → epoch).

Template fix: change the charted/date-token-filtered timestamp fields from
`datetime` to `date` (day granularity is all these reports need, and the
column then stores ISO text the analytics layer can compare):

- compliance `compliance_assessment.assessed_at`  → assessments-by-month
- todo       `todo_task.completed_at`             → throughput-by-week
- expense    `expense_report.reimbursed_at`       → spend-by-month
- content    `content_piece.published_at`         → published-by-month
- content    `content_publication.published_at`   → ROI dashboard (90d)

Deliberately NOT changed: `helpdesk_ticket.resolved_at` stays `datetime`
because SLA-resolution timing needs sub-day precision — its
"Resolutions by Day" chart stays empty until the platform binds epoch for
datetime columns. Documented the whole gotcha in AGENTS.md.

Verified: fresh boot stores all five as ISO text (typeof = text); the
compliance assessments-by-month chart renders a line (y-axis populated)
where it previously showed "No rows"; chart SQL count 0 → 4.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@os-zhuang
os-zhuang merged commit de4f39c into main Jun 18, 2026
3 checks passed
@os-zhuang
os-zhuang deleted the fix/timeseries-charts-datetime branch June 18, 2026 06:22
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