Skip to content

feat(webui): Increase precision of time range in guided UI from seconds to milliseconds. #1543

Merged
davemarco merged 6 commits into
y-scope:mainfrom
davemarco:timelinefix
Nov 4, 2025
Merged

feat(webui): Increase precision of time range in guided UI from seconds to milliseconds. #1543
davemarco merged 6 commits into
y-scope:mainfrom
davemarco:timelinefix

Conversation

@davemarco

@davemarco davemarco commented Nov 3, 2025

Copy link
Copy Markdown
Contributor

Description

I noticed a small issue where the total results displayed in ui was slightly lower than the amount ingested when running query with "all time". I believe this is due to a quirk of dayJS.unix() where it floors the timestamp to the nearest second. This PR replaces it with dayJS.valueOf() which includes milliseconds, and now the total results matches logs ingested.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

All time shows 1M results instead of slightly less than 1M with "all time"

Summary by CodeRabbit

  • Refactor
    • Improved timestamp handling in timeline and search queries to increase precision and accuracy of time-based filtering and retrieval, leading to more consistent query results across time ranges.

@coderabbitai

coderabbitai Bot commented Nov 3, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Introduced a MILLISECONDS_PER_SECOND constant and refactored timestamp handling to use valueOf() / MILLISECONDS_PER_SECOND in both buildSearchQuery and buildTimelineQuery, replacing previous Unix-based boundary calculations; minor formatting whitespace adjustments included.

Changes

Cohort / File(s) Summary
SQL Parser Timestamp Refactor
components/webui/client/src/sql-parser/index.ts
Added MILLISECONDS_PER_SECOND constant and updated timestamp calculations in buildSearchQuery and buildTimelineQuery to use .valueOf() / MILLISECONDS_PER_SECOND for width_bucket boundaries and BETWEEN clause conditions; minor formatting/whitespace tweaks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single file with localized, consistent timestamp conversion changes.
  • Review focus:
    • Verify correct division by MILLISECONDS_PER_SECOND in both buildSearchQuery and buildTimelineQuery.
    • Confirm numeric types/precision are preserved where these values are used in SQL string construction.

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately reflects the main change: increasing time range precision from seconds to milliseconds in the guided UI, which directly addresses the issue described in the PR objectives.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@davemarco davemarco requested a review from hoophalab November 3, 2025 18:38
@davemarco davemarco marked this pull request as ready for review November 3, 2025 18:38
@davemarco davemarco requested a review from a team as a code owner November 3, 2025 18:38

@hoophalab hoophalab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but when zooming in to only one log event, the timeline shows a bar for that log event, but result table is empty. We probably also need to do the same thing for buildSearchQuery to fix this.

--- a/components/webui/client/src/sql-parser/index.ts
+++ b/components/webui/client/src/sql-parser/index.ts
@@ -104,7 +104,7 @@ const buildSearchQuery = ({
     timestampKey,
 }: BuildSearchQueryProps): string => {
     let queryString = `SELECT ${selectItemList} FROM ${databaseName}
-WHERE to_unixtime(${timestampKey}) BETWEEN ${startTimestamp.unix()} AND ${endTimestamp.unix()}`;
+WHERE to_unixtime(${timestampKey}) BETWEEN ${startTimestamp.valueOf() / MILLISECONDS_PER_SECOND} AND ${endTimestamp.valueOf() / MILLISECONDS_PER_SECOND}`;

@davemarco

davemarco commented Nov 3, 2025

Copy link
Copy Markdown
Contributor Author

Okay good catch, i made change there as well

@davemarco davemarco requested a review from hoophalab November 3, 2025 20:10
@davemarco davemarco changed the title feat(webui): Increase precision of time range in timeline query in guided UI from seconds to milliseconds. feat(webui): Increase precision of time range in guided UI from seconds to milliseconds. Nov 3, 2025
@hoophalab hoophalab requested a review from junhaoliao November 3, 2025 21:10

@junhaoliao junhaoliao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deferring to @hoophalab 's review

@davemarco davemarco merged commit 8071934 into y-scope:main Nov 4, 2025
19 checks passed
junhaoliao pushed a commit to junhaoliao/clp that referenced this pull request May 17, 2026
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.

3 participants