Deduplicate analysis policy config and appid SQL predicate#12
Merged
Conversation
Extract the CURRENT_ANALYSIS_VERSION/STALE_ANALYSIS_DAYS/ PROCESSING_TIMEOUT_MINUTES env parsing into lib/analysisPolicy.js, and the appid ~ pattern / length SQL predicate into lib/appId.js, so they're each defined once instead of duplicated across models/Apps.js and the reporting scripts. Also document that apps.analysed is stamped on failed analyses too (it's really "last attempt time"), in a code comment and a migration comment. Pure refactor plus comments; no behavior change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
CURRENT_ANALYSIS_VERSION/STALE_ANALYSIS_DAYS/PROCESSING_TIMEOUT_MINUTESenv parsing (defaults 4 / 180 / 120) intolib/analysisPolicy.js, and use it inmodels/Apps.js,scripts/priority-report.js, andscripts/queue-status.jsinstead of three copies of the same parsing logic.appid ~ $n AND appid !~ '[.]$' AND length(appid) <= $mSQL predicate into a smallappIdSqlPredicate()helper inlib/appId.js, and use it inmodels/Apps.js(countQueuex2,nextApp) instead of three inline copies.apps.analysedis stamped on failed analyses too (it's really "last attempt time" for failed rows), with a code comment inupdateAnalysis(models/Apps.js) and a SQL comment next to the column inmigrations/000_apps.sql.Pure refactor plus comments — no behavior change. The scripts still call
dotenv.config()before requiringlib/analysisPolicy.js, matching the existing pattern.Test plan
npm test(node --test) — all 22 tests passnode -csyntax check on all changed files🤖 Generated with Claude Code