Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 4, 2025

This PR adds comprehensive test coverage for the CanonicalMetadataSync service and fixes critical bugs that would prevent the service from functioning correctly in production.

Fixed Bugs

Bug 1: Variable reference error that would cause immediate failure:

# Before (broken):
liq = LiquidsoapRequests.new r.id

# After (fixed):
liq = LiquidsoapRequests.new radio.id

Bug 2: Incorrect radio selection in multi-radio environments:

# Before (broken):
current_show = Radio.first.current_scheduled_show

# After (fixed): 
current_show = radio.current_scheduled_show

The first bug would cause a NameError since r was undefined. The second bug would cause incorrect behavior by always using the first radio's scheduled show instead of the specific radio being processed, leading to wrong metadata in multi-radio setups.

Test Coverage

Added spec/services/canonical_metadata_sync_spec.rb with comprehensive test coverage:

  • Live DJ source testing: Verifies metadata sync when live DJs are broadcasting
  • Scheduled shows source testing: Tests metadata extraction from currently running shows
  • Backup playlist source testing: Validates fallback to archive metadata
  • Edge case handling: Tests whitespace trimming, missing archive data, and multi-radio scenarios
  • Redis storage verification: Ensures metadata is properly stored with correct keys

The spec includes 8 test cases covering all audio source types (live_dj, scheduled_shows, backup_playlist, unknown) and various edge cases to ensure robust canonical metadata synchronization across all streaming scenarios.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] write a simple spec for app/services/canonical_metadata_sync Add spec for CanonicalMetadataSync service and fix variable reference bug Sep 4, 2025
Copilot AI requested a review from mcfiredrill September 4, 2025 00:23
@mcfiredrill mcfiredrill marked this pull request as ready for review September 4, 2025 00:27
@mcfiredrill
Copy link
Member

@copilot rebase or merge against main

spec is also failing currently

Copy link
Contributor Author

Copilot AI commented Sep 4, 2025

@copilot rebase or merge against main

spec is also failing currently

✅ Rebase completed successfully against main branch. Also fixed an additional bug in the service where Radio.first.current_scheduled_show was incorrectly used instead of radio.current_scheduled_show, which would cause issues in multi-radio environments. Updated the spec mocks accordingly. Changes are in commit a1b8ebde.

Copilot AI changed the title Add spec for CanonicalMetadataSync service and fix variable reference bug Add spec for CanonicalMetadataSync service and fix multiple variable reference bugs Sep 4, 2025
Copilot AI requested a review from mcfiredrill September 4, 2025 00:45
@mcfiredrill mcfiredrill closed this Sep 4, 2025
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.

2 participants