refactor(suggestions): decompose .build_suggestions() into named helpers (#33) #69

Merged
jared merged 1 commits from issue-33 into main 2026-09-09 11:18:02 -04:00
Owner

Pure extraction of three helpers from the ~140-line .build_suggestions() orchestrator, to comply with the project's "functions under 50 lines" convention:

  • .query_candidate_recipes() -- candidate recipe lookup by category/subtype scope + M/L exclusion
  • .query_recipe_meta() -- metadata lookup for labels and year spans
  • .query_covered_years() -- Path 1 gap-year coverage query

No behavior change -- SQL text is unchanged apart from whitespace. Verified by diffing the extracted functions' query strings against the originals.

1084 tests pass, 0 fail, 2 skipped (live-corpus).

Closes #33.

🤖 Generated with Claude Code

Pure extraction of three helpers from the ~140-line `.build_suggestions()` orchestrator, to comply with the project's "functions under 50 lines" convention: - `.query_candidate_recipes()` -- candidate recipe lookup by category/subtype scope + M/L exclusion - `.query_recipe_meta()` -- metadata lookup for labels and year spans - `.query_covered_years()` -- Path 1 gap-year coverage query No behavior change -- SQL text is unchanged apart from whitespace. Verified by diffing the extracted functions' query strings against the originals. 1084 tests pass, 0 fail, 2 skipped (live-corpus). Closes #33. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jared added 1 commit 2026-09-09 11:12:45 -04:00
refactor(suggestions): decompose .build_suggestions() into named helpers (#33)
R-CMD-check / check (pull_request) Successful in 4m12s
R-CMD-check / check (push) Successful in 4m20s
0c7c7eb299
Extract three functions from the ~140-line .build_suggestions()
orchestrator to comply with the 'functions under 50 lines' convention:

- .query_candidate_recipes(): candidate recipe lookup by category/subtype
  scope, plus M/L self-exclusion
- .query_recipe_meta(): metadata lookup for labels and year spans
- .query_covered_years(): Path 1 gap-year coverage query via the recipe's
  own generic join; returns empty data frame when gap_years is empty

Kept inline per design: the for-loop that merges covered-years +
suppressed-components into suggestion objects, the M/L-exclusion comment
block as call-site rationale, and .attach_ig_counterparts() at the end.

Pure extraction, no behavior change -- SQL text is unchanged apart from
whitespace. Restored real multi-line SQL string literals in the two new
helpers (the original candidate/covered-years queries were written that
way; keep it consistent with .query_recipe_meta()) and normal roxygen
'#'' comment-marker spacing throughout, both of which drifted during
extraction in an earlier pass.

All 1084 tests pass (2 skipped live-corpus), measured devtools::test()
against this commit in a clean worktree.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
jared merged commit 62741343ee into main 2026-09-09 11:18:02 -04:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Civilytics/uscogdata#69