Repository navigation
deduce missing set from reference - #77
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
CardBuilder::applyPrintingIdentity() (src/Builder/CardBuilder.php:139) only links a card to a Set when the source payload has a cardSet.reference field. Some prints (e.g. ALT_EOLECB_A_AX_106_C, a Roots of Corruption Collector Booster promo pulled from the Altered API) come back with no cardSet from upstream, so card.set stays NULL. Since CardGroupSetFilter/set.reference filters use an inner JOIN card.set, any card with set = NULL is silently excluded — exactly what you're seeing.
Fix
The card's own reference already encodes the set (ALT_ — same convention already used for variation), and it matches Set.reference for every set in card_set.csv (e.g. EOLECB). I added a fallback in CardBuilder.php: when cardSet.reference is missing, derive it from the card reference's 2nd segment before looking it up.
This fixes it going forward for every import path (app:import:cards, app:import:equinox, and the live API scraper).
Backfill for already-imported cards
Fixing the builder doesn't retroactively repair cards already sitting in the DB with set_id = NULL. I added FixMissingCardSetCommand.php (app:fix:missing-card-set, with --dry-run) that finds those cards, derives the set from their reference the same way, and backfills set_id/set_date. I couldn't run it here — no PHP/DB available in this sandbox — so run it yourself once you're ready:
php bin/console app:fix:missing-card-set --dry-run
php bin/console app:fix:missing-card-set
Any leftover "unmapped" references it reports would be genuine oddballs (reference doesn't match any known Set.reference) worth a manual look.