Repository navigation
Find parent issues by variant UPC and SKU - #670
Conversation
Extend API and website identifier filters to include variant covers without duplicate issues. Cover exact UPC/SKU and API UPC prefix searches with regression tests and document the behavior. Refs Metron-Project#669
|
I'm pretty busy this week, but with some luck, I'll get a chance to look at this before the weekend. |
bpepple
left a comment
There was a problem hiding this comment.
Thanks for this, Eric! Matching variants on the exact upc and sku filters fixes a real gap. A variant's full 17-digit UPC (or its SKU) can never match the parent issue, so those covers couldn't be found before. I'd like to keep those changes.
I'd like to leave upc_starts_with as it was, though, matching only the main cover's UPC.
US direct-market comics usually give every cover of an issue the same 12-digit UPC-A. Only the 5-digit add-on changes (issue number, cover, printing). Using your example, 761941387888 + 00621, the main cover is …00611, so a 12-digit scan already finds the parent issue through its own UPC. A scanner that drops the add-on, which most mobile scanner libraries do, can't tell the covers apart anyway, so returning the parent issue is the best it can do, and it already does that today.
I checked this against a copy of the production data (~25k variants with UPCs):
- ~24.5k variants share their parent's 12-digit base, so the variant branch finds nothing extra for them.
- 84 variants belong to a parent with no UPC. The better fix there is to add the parent's UPC.
- ~310 variants have a different base, and most of those are bad data (SKUs typed into the UPC field, typos, 18-digit UPCs). Prefix-matching on variants would mostly end up matching that bad data.
The join plus .distinct() also makes these lookups about 3× slower locally (~95 ms → ~280 ms). That's worth paying for the exact filters, but not for the prefix filter that scanner apps call most.
Could you make these changes?
- Change
upc_starts_withback to a plainCharFilteronupcwithlookup_expr="startswith", and revert its label and README text. - In
test_issue_upc_filters.py, drop theapi_prefixparam from the variant-only tests (test_upc_variant_cover_onlysets up a parent and variant with entirely different bases, which doesn't really happen). If you want to keep prefix coverage, a test that a 12-digit prefix finds the parent through its main cover would be great. - Update the README note so it says the variant matching applies to
upcandskuonly.
Everything else looks good. Thanks again!
|
Thanks for explaining the mobile scanner use case. No problem at all. Changes forthcoming presently. |
Address maintainer feedback by restoring the original UPC prefix filter and documentation. Limit variant tests to exact lookups and cover 12-digit main-cover prefix searches separately. Refs Metron-Project#670
|
213 tests pass with the restored |
The variant-only test gave the parent a UPC with an entirely different 12-digit base from its variant, which doesn't happen with direct-market comics. Use the main cover's UPC instead, so the parent and variant share the UPC-A and differ only in the 5-digit add-on. The full variant UPC still matches only through the variant. Also add readable parametrize IDs.
bpepple
left a comment
There was a problem hiding this comment.
Ok, made a minor change to a test, but otherwise it's good. Thx!
Description
Fixes #669.
Issue searches check only the main cover's UPC or distributor SKU, even when a matching value is stored on a variant. This change checks both the issue and its variants for exact UPC/SKU searches in the API and website, and for the API's
upc_starts_withfilter.A shared
IssueCoverIdentifierfilter returns each matching parent issue once and preserves other supplied filters. The response format stays the same: clients retrieve issue details to inspect the variants and identify the matching cover. SKU matching remains case-insensitive and exact.For example, both UPC
76194138788800621and SKU0625DC043now find Absolute Martian Manhunter #6 through its Amy Reeder Cover B variant.Updates the API documentation and adds regression tests using synthetic fixtures, independent of production or imported comic data.
Validation
222 tests passed, covering the new UPC/SKU cases and the existing issue API and website suites:
metron.local_settingsis an untracked local configuration selecting PostgreSQL and local caching. The tests themselves use the project's existing fixtures. The full repository test suite was not run.Regression coverage includes main and variant matches, duplicate prevention, empty/no-match searches, combined filters, case-insensitive SKU matching, and rejection of partial SKU values. Also verified all five cover SKUs and both example UPCs against a locally running instance.
Checklist