Repository navigation
fix(action-center): score actions on nights the generator skips, and backfill unscored ones - #1145
Conversation
…backfill unscored ones Priority scores (ansvisor#1071, migration 00144) are worked out when an action is created and again by the nightly generator. Actions opened before then show "—" in the Priority Score column until the next nightly pass, and completed or dismissed ones never get a score. The generator also doesn't run when a brand's signal pass is skipped for no fresh results, so such a brand's actions stayed unscored, or kept old scores. - rescoreBrandActions (priority-data.js) scores a brand's actions in one go: their open signals and the prompts' demand are read once. - A skipped signal pass now rescores the brand's active actions, best effort; the ledger row records how many. - scripts/rescore-actions.js scores every action with no score yet, in any status, for one brand or --all. Safe to re-run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk Every action on app.ansvisor.com shows "—" for Priority Score. They were all created before #1071, and no nightly pass has run since that deploy. The 05:00 (TR) pass should score the active ones. This PR also rescores on skipped nights and adds a backfill. After it deploys, could you run this once on production? It scores only actions without a score, closed ones included, so re-running it is safe. Server only, no migration. |
gkhngyk
left a comment
There was a problem hiding this comment.
Checked on main with the rest of tonight's PRs stacked on top: the priority-data and signal pass tests pass, and CI is green. rescoreBrandActions reads the brand's open signals and prompt demand once, and a failed rescore on a skipped night only logs, so it can't fail the pass. With #1144, the backfill script also scores deleted actions; they stay hidden, so that's harmless.
|
@gkhngyk A quick check on #1145: did If it hasn't run yet, it's safe to run now. It only touches actions with no score, closed and deleted ones included. A re-run picks up where a capped run stopped (1,000 actions per brand). To check afterwards, |
Summary
Every action in the Action Center shows "—" for Priority Score on app.ansvisor.com. This PR closes the gaps behind it and adds a one-off backfill. The product owner reported the problem.
Why the scores are empty
Read-only, in the product owner's browser: all 47 actions of their brand come back with
priorityScore: null. "Highest Priority" reads "—" too.So the first nightly pass after the deploy should score the active ones. Two gaps remain after that:
runSignalPasscalls the generator only when signals were recorded. A brand whose pass is skipped (no_fresh_results) never has its actions rescored. They stay "—", or keep old scores.Changes
rescoreBrandActions(brandId, { now, statuses, unscored })(priority-data.js)new,in_progress,on_hold).statuses: nulltakes every status;unscored: truetakes only actions with no score.pass.js)detail.actionsrecords{ rescored }.scripts/rescore-actions.js <brandId|--all>--allincludes paused brands, because their actions are still listed.No migration. No web change.
Deploy
After this deploys, run once on production:
This scores the actions now rather than at the next nightly pass, and gives closed ones a score.
Related issue
None. The product owner reported it.
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
priority_score,priority_level,priority_reasonandpriority_updated_atto null.server/, runnode src/scripts/rescore-actions.js <brandId>. It prints{"scored":N}.{"scored":0}.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/): not run, no web changeyarn typecheckpasses (run fromweb/): not run, no web changeyarn format:checkpasses (run fromweb/): not run, no web changeAlso run:
server:npm run format,npm run lintandnpm test(1539) pass.priority-data.test.js: each action is scored from its own open signals, and signals and demand are read once per brand. Also covered: the status andunscoredfilters, a brand with no actions, and a failed save or demand read.pass.test.js: a skipped night rescores and records it, a failed rescore still writes the ledger row, and a recorded night leaves scoring to the generator.npm run version:check: fails as onmain(compose images 0.2.0, packages 0.3.0). The failure predates this PR and is not touched here.{"scored":2}and the page showed 82 (High) and 63 (Medium). A second run printed{"scored":0}.🤖 Generated with Claude Code