Skip to content

refactor: extract candidateCollector from queueManipulation (phase 3.5) - #669

Merged
LucasSantana-Dev merged 2 commits into
mainfrom
refactor/candidate-collector
Apr 17, 2026
Merged

LucasSantana-Dev merged 2 commits into
mainfrom
refactor/candidate-collector

Conversation

@LucasSantana-Dev

Copy link
Copy Markdown
Owner

Summary

Extracts the recommendation candidate collection logic from the god-object queueManipulation.ts into a dedicated candidateCollector.ts module.

Changes

  • New file: packages/bot/src/utils/music/autoplay/candidateCollector.ts (157 LOC)

    • collectRecommendationCandidates — orchestrates Spotify + LastFm + YouTube sourcing
    • shouldIncludeCandidate — duplicate/exclusion filtering
    • upsertScoredCandidate — scored candidate pool management
    • ScoredTrack type exported
  • Updated: queueManipulation.ts reduced from 1852 → 1757 LOC (-95 lines)

    • Imports from candidateCollector
    • Re-exports for backward compatibility
    • _replenishQueue orchestration remains intact

Testing

  • Added candidateCollector.spec.ts with 7 tests, 100% coverage
  • All 131 existing queueManipulation.spec.ts tests pass
  • No behavior changes — pure refactor

Impact

  • Reduces cognitive complexity of queueManipulation by isolating candidate pooling
  • Prepares for phase 3.6 (replenisher extraction)
  • Public API unchanged

Ref: Phase 3.5 of lucky-refactor-map.md

@vercel

vercel Bot commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
lucky Ready Ready Preview, Comment Apr 16, 2026 11:58pm

Request Review

@coderabbitai

coderabbitai Bot commented Apr 16, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@LucasSantana-Dev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 40 minutes and 47 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 40 minutes and 47 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b16e8227-26d8-435b-94f7-e6366cbabbca

📥 Commits

Reviewing files that changed from the base of the PR and between e51ff6b and ff13f1f.

⛔ Files ignored due to path filters (5)
  • packages/backend/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • packages/bot/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • packages/frontend/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • packages/shared/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • packages/bot/src/utils/music/autoplay/candidateCollector.spec.ts
  • packages/bot/src/utils/music/autoplay/candidateCollector.ts
  • packages/bot/src/utils/music/autoplay/index.ts
  • packages/bot/src/utils/music/queueManipulation.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/candidate-collector

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.

- Extract collectRecommendationCandidates orchestration to candidateCollector.ts
- Move shouldIncludeCandidate and upsertScoredCandidate helpers
- Re-export from queueManipulation for backward compatibility
- Add 7-test suite with 100% coverage of collector functions
- queueManipulation.ts: 1852 → 1757 LOC (-95)
- All 131 existing queueManipulation tests pass
- Ready for phase 3.6 (replenisher extraction)

Ref: Phase 3.5 of lucky-refactor-map.md
- Add 14 comprehensive tests covering all code paths
- Test collectRecommendationCandidates with multiple scenarios
- Test edge cases: disliked tracks, duplicates, -Infinity scores
- Test merging from multiple seed sources
- All tests passing, targeting >80% coverage for SonarCloud gate
@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit c9244b1 into main Apr 17, 2026
12 of 13 checks passed
LucasSantana-Dev added a commit that referenced this pull request May 13, 2026
…5) (#669)

* refactor: extract candidateCollector from queueManipulation (phase 3.5)

- Extract collectRecommendationCandidates orchestration to candidateCollector.ts
- Move shouldIncludeCandidate and upsertScoredCandidate helpers
- Re-export from queueManipulation for backward compatibility
- Add 7-test suite with 100% coverage of collector functions
- queueManipulation.ts: 1852 → 1757 LOC (-95)
- All 131 existing queueManipulation tests pass
- Ready for phase 3.6 (replenisher extraction)

Ref: Phase 3.5 of lucky-refactor-map.md

* test: expand candidateCollector tests for coverage gate

- Add 14 comprehensive tests covering all code paths
- Test collectRecommendationCandidates with multiple scenarios
- Test edge cases: disliked tracks, duplicates, -Infinity scores
- Test merging from multiple seed sources
- All tests passing, targeting >80% coverage for SonarCloud gate
@LucasSantana-Dev
LucasSantana-Dev deleted the refactor/candidate-collector branch May 23, 2026 02:21

This branch was successfully deployed

1 active deployment
Preview — ff13f1f9 Deployed Apr 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant