ML-153: move MusicBrainz data transforms from Record

This commit is contained in:
Claudio Ortolina
2026-04-30 13:19:25 +01:00
parent b8b3b24ffa
commit 13068aa0ac
3 changed files with 77 additions and 38 deletions
@@ -1,9 +1,10 @@
---
id: ML-153
title: Move MusicBrainz data transformations out of Record schema
status: To Do
status: Done
assignee: []
created_date: '2026-04-30 10:48'
updated_date: '2026-04-30 12:20'
labels:
- refactor
- records
@@ -36,9 +37,21 @@ Update callers in:
## Acceptance Criteria
<!-- AC:BEGIN -->
- [ ] #1 `parse_artists/1`, `parse_subtype/2`, `parse_secondary_types/1`, and `attrs_from_release_group/1` are moved to `MusicBrainz` modules
- [ ] #2 `Record` schema retains only struct introspection and presentation helpers
- [ ] #3 All callers are updated to use the new locations
- [ ] #4 Full test suite passes
- [ ] #5 `@moduledoc` on moved functions explains their purpose
- [x] #1 `parse_artists/1`, `parse_subtype/2`, `parse_secondary_types/1`, and `attrs_from_release_group/1` are moved to `MusicBrainz` modules
- [x] #2 `Record` schema retains only struct introspection and presentation helpers
- [x] #3 All callers are updated to use the new locations
- [x] #4 Full test suite passes
- [x] #5 `@moduledoc` on moved functions explains their purpose
<!-- AC:END -->
## Implementation Notes
<!-- SECTION:NOTES:BEGIN -->
`parse_artist_credits/1` and `parse_record_type/2` moved to `MusicBrainz.ReleaseGroup` — these are pure MusicBrainz data parsing functions with no Record schema knowledge. `attrs_from_release_group/1` stays on `Record` because it maps MusicBrainz response fields to Record changeset keys (an implicit Record schema dependency). The Record schema now delegates parsing to `ReleaseGroup.parse_artist_credits/1` and `ReleaseGroup.parse_record_type/2`, keeping the coupling boundary clean: MusicBrainz modules parse MusicBrainz data; the Record schema owns its own field mapping.
<!-- SECTION:NOTES:END -->
## Final Summary
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Moved `parse_artist_credits/1` and `parse_record_type/2` to `MusicBrainz.ReleaseGroup`. `attrs_from_release_group/1` kept on `Record` to avoid reverse dependency — it now delegates parsing to the new MusicBrainz functions. `Record.update_artists/1` uses `ReleaseGroup.parse_artist_credits/1`. All 884 tests pass.
<!-- SECTION:FINAL_SUMMARY:END -->