Skip to content

Functional changes for display_artist on 3NF schema#21

Merged
darrell-k merged 10 commits into
darrell-k:display_artistfrom
Rouzax:pr/darrell-3nf-rebase
May 19, 2026
Merged

Functional changes for display_artist on 3NF schema#21
darrell-k merged 10 commits into
darrell-k:display_artistfrom
Rouzax:pr/darrell-3nf-rebase

Conversation

@Rouzax
Copy link
Copy Markdown

@Rouzax Rouzax commented May 18, 2026

Summary

Ports the functional display_artist changes onto your 3NF contributor_display schema, as discussed in PR #20.

  • Replace tag swap with capture-before-defer: extracts display strings from ALBUMARTIST/ARTIST without mutating tag values. Fixes scenario 3 data loss.
  • Rescan path: updateOrCreateBase and _postCheckAttributes now populate display_contributor on track update, not just fresh scan.
  • Track-level display: populates tracks.display_contributor and contributor_track_display junction table for ARTIST/TRACKARTIST roles. Queries return track-level display_artist via aliased JOINs.
  • Preference gate: usePluralArtistTags (default OFF). When ON, ALBUMARTISTS/ARTISTS entries replace singular tags for contributor creation.
  • FTS indexing: display names indexed in fulltext search via contributor_display JOINs.
  • Helper extraction: _getOrCreateDisplayContributor reuses the lookup/insert pattern across _newTrack, _postCheckAttributes, and both album/track paths.

Schema is untouched. All changes work with your contributor_display table, integer FK columns, and junction tables as-is.

Supersedes #20 (flat-column approach).

Test plan

  • Fresh scan with pref OFF: contributor_display populated, albums.display_contributor set, API returns display_artist
  • Fresh scan with pref ON: individual contributors created from plural tags, no joined-string contributor rows
  • Rescan after retag: display_contributor updates on existing tracks
  • FTS search for display string (e.g. "Chick Corea & Gary Burton") finds album
  • Smoketest and verifyStrings pass

@darrell-k
Copy link
Copy Markdown
Owner

The new setting is not sticking when I try to change it to enabled. Probably needs adding to the list of prefs in Slim/Web/Settings/Server/Behavior.pm

You should also add a $prefs->setchange rule to trigger the rescan.

@darrell-k
Copy link
Copy Markdown
Owner

darrell-k commented May 18, 2026

I forgot to push schema_clear.sql to the branch. Done now.

Comment thread Slim/Schema.pm
$attributes->{$singular} = \@individuals;
}
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not working. example tags:

ALBUMARTIST: Bill Evans Trio with Scott LaFaro & Paul Motian
ALBUMARTISTS: Bill Evans; Bill Evans Trio; Scott LaFaro; Paul Motian

Results in only a single contributor being created "Bill Evans Trio with Scott LaFaro & Paul Motian" (I forced the new pref to "1").

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably because $attributes->{ALBUMARTISTS} is not an array?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The code assumed an arrayref but ALBUMARTISTS arrives as a scalar when written as a single semicolon-joined field (e.g. "Bill Evans; Scott LaFaro"). Fixed by routing through splitTag which handles both arrayrefs (pass-through) and scalars (splits on the configured splitList separator). Added a test fixture (fixture 23) that writes scalar plural tags to catch this going forward.

Rouzax added 9 commits May 19, 2026 07:46
Signed-off-by: Rouzax <GitHub@mgdn.nl>
In updateOrCreateBase, capture albumDisplayArtist and trackDisplayArtist
from the attributeHash before _preCheckAttributes strips/defers them.
Pass both values to _postCheckAttributes, which now calls
_getOrCreateDisplayContributor for each, writes display_contributor to
the track row, and forwards both IDs to _createOrUpdateAlbum and
_createContributorRoleRelationships. Without this, rescanning an
existing track never updated display_contributor.

Signed-off-by: Martijn Frazer <claude@mgdn.nl>
Signed-off-by: Rouzax <GitHub@mgdn.nl>
Register usePluralArtistTags in Behavior.pm prefs list so the web UI
can save it. Add to the setChange wipecache list so toggling the pref
triggers a rescan. Handle scalar plural tags (e.g. semicolon-joined
ALBUMARTISTS from TXXX) by routing through splitTag instead of
requiring an arrayref.

Signed-off-by: Rouzax <GitHub@mgdn.nl>
@Rouzax Rouzax force-pushed the pr/darrell-3nf-rebase branch from c2f0d66 to 00cc68c Compare May 19, 2026 05:58
@Rouzax
Copy link
Copy Markdown
Author

Rouzax commented May 19, 2026

Fixed in the latest push (00cc68c -> 81b63ba):

  1. Pref not sticking: added usePluralArtistTags to the prefs list in Slim/Web/Settings/Server/Behavior.pm.
  2. Rescan trigger: added to the setChange wipecache list in Slim/Utils/Prefs.pm so toggling the pref triggers a rescan.
  3. Scalar plural tags: the code assumed ALBUMARTISTS/ARTISTS would always be an arrayref (true for Vorbis multi-value, but not for a single field with semicolons). Now routes through splitTag which handles both arrayrefs and scalar strings. Also improved the description text to be clearer for non-technical users.

Rebased onto your schema_clear.sql commit as well.

@darrell-k
Copy link
Copy Markdown
Owner

@Rouzax Thanks, I'm going to merge this, and the Material Skin PR and offer it to the forum for further testing.

@darrell-k darrell-k merged commit 5258c10 into darrell-k:display_artist May 19, 2026
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