Repository navigation
fix(reports): show the Site Audit score in points, compared with the same page's audit before - #2133
Merged
Merged
Conversation
…same page's audit before A report's Site Audit Score section printed site_audits.total_score on its 0-1 scale rounded to one decimal, so a page Site Audit scores 64 read 0.6. Its change compared the brand's audit before, whichever page that was, and carried a % sign. The snapshot now stores the score in 0-100 points as Site Audit rounds it, the score of the same page's audit before (the Pages list's page key), and scale: 100. The page and PDF show the change in points. Reports saved before keep their payload and now read "~60", with no change. The summary prompt says what auditScore is. Help: one sentence in Read a report. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
8 of 13 tasks
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.
Summary
The Site Audit Score section of a report (Reports › a report, and its PDF) showed the wrong number.
site_audits.total_scoreis stored on a 0–1 scale, and Site Audit shows it as 0–100 points (audit-report.tsxmultiplies by 100). The report's snapshot (getAuditSnapshotinweb/src/lib/actions/reports.ts) only rounded it to one decimal. So a page that scores 64 in Site Audit read 0.6 in the report.The same section had two more problems:
Delta, so a 10-point change read "+0.1%".The AI executive summary got the same snapshot. It saw
"totalScore": 0.6, with no note on what the field means.Found while building #2131 (open point 6 there).
What changes
scale: 100, to mark the new shape.auditPageKeyfollows the same rule aspageKeyinserver/src/lib/audit/history.js.findPreviousCompletedAudit.Delta/DeltaTexttakeunit=""for this; every other change keeps its %.server/src/routes/reports.js) says thatauditScoreis one page's score in 0–100 points, written without a % sign. It also says thatpreviousScoreis that page's audit before, not the previous period.Code
web/src/lib/reports/audit-score.ts, with pure functions tested on their own:auditPageKey;auditSnapshotFrom(rows), which builds the snapshot;auditScoreView(auditScore), which gives what the page and the PDF show, for new and old payloads.ReportAuditScoregainsscale?: 100. Its comments say which scale each payload uses.Help:
help/reports/visibility-reports.md› Read a report gets one sentence. Site Audit Score is the exception to "compared with the previous period". It shows the latest audit of one page, scored 0 to 100, with the change since that page's audit before.approved-articles.jsonis regenerated.No migration. No new strings: the section's existing
reports.auditScoreandauditedOnare kept.Related issue
None. Found while building #2131 (Site Audit score range).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd web && npx vitest run src/lib/reports "src/app/[locale]/(dashboard)/dashboard/reports/[id]" src/lib/help.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)help/(or no user-visible change) — see help/README.mdFull checks on this branch (d57f2be), built on main 8be573d. The branch still merges into main cleanly.
format:checkandtypecheckpass.linthas 0 errors; its 7 warnings are old ones in files this PR doesn't touch.yarn testpasses 975 files (10,411 tests, 1 skipped).yarn buildpasses with CI's placeholder env.format:checkandlintpass.npm testpasses 415 files (5,707 tests, 4 skipped).Generated by Claude Code