Skip to content

fix: correct dashboard footer date range by sorting on tweet IDs#5

Draft
ccage-simp wants to merge 2 commits into
mainfrom
fix/viz-date-range
Draft

fix: correct dashboard footer date range by sorting on tweet IDs#5
ccage-simp wants to merge 2 commits into
mainfrom
fix/viz-date-range

Conversation

@ccage-simp
Copy link
Copy Markdown
Owner

@ccage-simp ccage-simp commented Apr 10, 2026

Description

This PR fixes the date range displayed in the ft viz dashboard footer, which was previously showing incorrect values due to how SQLite sorts raw Twitter date strings.

Before:

image

After:

image

The Problem

The dashboard used MIN(posted_at) and MAX(posted_at) to calculate the range. Because Twitter legacy dates start with the day of the week (e.g., Fri Apr 01... vs Wed Sep 30...), SQLite performs an alphabetical sort rather than a chronological one. This resulted in a bogus range (e.g., Fri Apr 01 → Wed Sep 30) that ignored the actual years.

The Fix

  1. Accurate Range Query: Updated the query in src/bookmarks-viz.ts to retrieve the earliest and latest bookmarks by sorting on the mathematically-sequential tweet_id (Snowflake ID) instead of the text date strings.
  2. Clean Formatting: Added a formatHeaderDate helper to parse the resulting timestamps and display them cleanly as MMM YYYY (e.g., Mar 2018 → Apr 2026) instead of raw 16-character string slices.
  3. Visual Polish: Improved the spacing and icons in the dashboard header for better readability.

Testing

  • Unit Test: Added tests/bookmarks-viz-range.test.ts to verify that chronological sorting of Snowflake IDs correctly establishes the date range even when the alphabetical order of the timestamp strings is inverted.

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