Skip to content

Comments

Add Last.fm auto-sync and fix auto-tagging#247

Merged
fiddur merged 1 commit intodevelopfrom
feat/lastfm-auto-sync-retag
Feb 24, 2026
Merged

Add Last.fm auto-sync and fix auto-tagging#247
fiddur merged 1 commit intodevelopfrom
feat/lastfm-auto-sync-retag

Conversation

@fiddur
Copy link
Owner

@fiddur fiddur commented Feb 24, 2026

Summary

  • Auto-sync: Last.fm scrobbles are automatically synced before tag/daily-summary queries if the last sync is >30 minutes old (same pattern as Oura/RescueTime/Calendar)
  • Retroactive tagging: New rules are applied to all existing scrobbles in raw_records
  • Rule cleanup: Deleting a rule also removes its auto-generated tags
  • Full re-tag: New POST /lastfm/retag endpoint and retag_lastfm_scrobbles MCP tool to delete all auto-tags and reapply all rules from scratch

Test plan

  • Unit tests: 40 tests in lastfm-sync.test.ts (including new scrobbleRecordToScrobble, applyRuleRetroactively, cleanupRuleTags, retagAllScrobbles)
  • Integration tests: 4 new tests in tags.integration.test.ts for hardDeleteTagsBySource and hardDeleteTagsByExternalIdPrefix
  • All 854 tests pass across 50 test files
  • Manual: Create a rule via MCP/REST and verify tags_applied > 0 for existing scrobbles
  • Manual: Delete a rule and verify auto-tags are cleaned up
  • Manual: Call retag_lastfm_scrobbles and verify full re-tag works
  • Manual: Query tags and verify Last.fm auto-syncs when stale

🤖 Generated with Claude Code

- Auto-sync: scrobbles are fetched automatically before tag/daily-summary
  queries if last sync is >30 minutes old (same pattern as Oura/RescueTime)
- Retroactive tagging: new rules are applied to all existing scrobbles
- Rule cleanup: deleting a rule also removes its auto-generated tags
- Full re-tag: new POST /lastfm/retag endpoint and retag_lastfm_scrobbles
  MCP tool to delete all auto-tags and reapply all rules from scratch
- New DB functions: hardDeleteTagsBySource, hardDeleteTagsByExternalIdPrefix,
  getAllScrobbles with integration tests
- Updated api-spec with new response schemas

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

❌ Patch coverage is 37.09677% with 78 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.31%. Comparing base (01d66a5) to head (df20065).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
apps/backend/src/lastfm-router.ts 0.00% 29 Missing ⚠️
apps/backend/src/services/sync-provider.ts 0.00% 19 Missing ⚠️
apps/backend/src/db/raw-records.ts 7.69% 12 Missing ⚠️
apps/backend/src/mcp/lastfm-tools.ts 45.00% 11 Missing ⚠️
apps/backend/src/services/queries.ts 0.00% 6 Missing ⚠️
apps/backend/src/api.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #247      +/-   ##
===========================================
+ Coverage    27.26%   27.31%   +0.05%     
===========================================
  Files          176      176              
  Lines        23751    23863     +112     
  Branches      2122     2134      +12     
===========================================
+ Hits          6476     6519      +43     
- Misses       17236    17305      +69     
  Partials        39       39              
Flag Coverage Δ
android 8.57% <ø> (ø)
backend 57.37% <37.09%> (-0.21%) ⬇️
web 3.02% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fiddur fiddur merged commit c9997f0 into develop Feb 24, 2026
4 checks passed
@fiddur fiddur deleted the feat/lastfm-auto-sync-retag branch February 24, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant