Skip to content

fix: differences in downloads embed version#2932

Open
graphieros wants to merge 4 commits into
mainfrom
embed-chart-fix
Open

fix: differences in downloads embed version#2932
graphieros wants to merge 4 commits into
mainfrom
embed-chart-fix

Conversation

@graphieros

@graphieros graphieros commented Jun 18, 2026

Copy link
Copy Markdown
Member

Follow up to #2833

This fixes 2 imprecisions in the embed-chart:

  1. averageWindow data correction was set to 1, instead of 0 (no data correction is to be applied on the embed version).
  2. the end date was forced to date.now instead of the same date as the one used in TrendsChart.vue, resulting in a different last value.

To test:

  • go to the stats page and open the 'Embed this chart' details under the downloads chart
  • the preview chart should have the same shape and last value as the main chart (make sure you have unset any data correction settings)

Other:

  • Bump vue-data-ui:
    • 3.21.9 (release notes)
    • 3.21.10 (release notes). This fixes a bug that does not occur with the way our charts are setup, but we stay fresh:)

@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs.npmx.dev Ready Ready Preview, Comment Jun 20, 2026 7:53am
npmx.dev Ready Ready Preview, Comment Jun 20, 2026 7:53am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
npmx-lunaria Ignored Ignored Jun 20, 2026 7:53am

Request Review

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

buildNormalisedTrendsDataset drops the nowMs option, resolving referenceMs via endDateMs ?? Date.now() only. The SVG embed utility gains a dateIsoToUtcMs helper, derives effectiveEndDateMs from the effective end date ISO string, passes it as endDateMs, sets averageWindow to 0, and reuses the computed ISO value for the dash-last-point check. Tests are updated to match. A minor dependency update to vue-data-ui is also included.

Changes

Remove nowMs and align endDateMs usage

Layer / File(s) Summary
Drop nowMs from buildNormalisedTrendsDataset
shared/utils/trends-chart.ts
Removes nowMs from the options type and from the referenceMs fallback chain, leaving options.endDateMs ?? Date.now() as the only resolution path.
Compute effectiveEndDateMs and update SVG embed caller
server/utils/embed-downloads-svg.ts
Adds dateIsoToUtcMs helper, computes effectiveEndDateMs from getEffectiveEndDateIso, passes it as endDateMs instead of nowMs: Date.now(), sets averageWindow to 0, and removes the late effectiveEndDateIso reassignment so the earlier value is reused for the dash-last-point decision.
Update tests for nowMs removal
test/unit/shared/utils/trends-chart.spec.ts
Removes nowMs from two test invocations, replaces the nowMs-fallback test with a Date.now() spy-based assertion, and updates the weekly-granularity test to expect predictionPoints: 0 and referenceMs from endDateMs.

Possibly related PRs

  • npmx-dev/npmx.dev#2833: Both PRs touch the shared trends-chart normalisation logic used by the downloads embed SVG—this PR changes buildNormalisedTrendsDataset's reference timestamp and endDate handling, whilst the retrieved PR refactors the /api/embed/downloads.svg endpoint that depends on those same normalised dataset and configuration inputs.

Suggested reviewers

  • alexdln
  • ghostdevv
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the main issue: fixing imprecisions in the downloads embed chart version, which aligns with the changeset objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly relates to the changeset, explaining specific fixes for embed-chart imprecisions including averageWindow correction and end date alignment, matching the code changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch embed-chart-fix

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.

@graphieros graphieros changed the title fix: use same endDate as trends chart, unset averageWindow correction fix: differences in downloads embed version Jun 18, 2026
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@graphieros graphieros requested a review from a team June 18, 2026 15:56
@socket-security

socket-security Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedvue-data-ui@​3.21.10901009796100

View full report

@github-actions

Copy link
Copy Markdown

e18e dependency analysis

No dependency warnings found.

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