Skip to content

Orphan detection for attributes + linking orphans#854

Merged
hadijafar merged 6 commits intomainfrom
orphan-tests-for-attributes-and-categories
Mar 12, 2026
Merged

Orphan detection for attributes + linking orphans#854
hadijafar merged 6 commits intomainfrom
orphan-tests-for-attributes-and-categories

Conversation

@hadijafar
Copy link
Copy Markdown
Contributor

@hadijafar hadijafar commented Jan 30, 2026

resolves https://github.com/orgs/shop/projects/165/views/22?sliceBy%5Bvalue%5D=hadijafar&pane=issue&itemId=153383691&issue=shop%7Cissues-taxonomy%7C187

Add integration test for orphan detection in product taxonomy

Added a new integration test file that detects orphaned elements in the product taxonomy system. The test ensures data integrity by verifying that all taxonomy components are properly connected.

The test validates three key relationships:

  • All values are referenced by at least one attribute
  • All attributes belong to at least one category

Each test provides detailed output when orphans are found, making it easier to identify and fix disconnected taxonomy elements.

@hadijafar hadijafar changed the title Add integration test for orphan values detection Add orphan detection test and new printer/medical alarm features Jan 30, 2026
Copy link
Copy Markdown
Contributor Author

hadijafar commented Jan 30, 2026

@hadijafar hadijafar force-pushed the orphan-tests-for-attributes-and-categories branch from 0d50a81 to 688442f Compare January 30, 2026 21:08
@hadijafar hadijafar changed the title Add orphan detection test and new printer/medical alarm features Add orphan detection tests for attributes and categories Jan 30, 2026
@hadijafar hadijafar force-pushed the orphan-tests-for-attributes-and-categories branch from 688442f to 2bb44cf Compare January 30, 2026 21:15
@hadijafar hadijafar marked this pull request as ready for review January 30, 2026 22:08
@hadijafar
Copy link
Copy Markdown
Contributor Author

39 orphaned attributes were found and this is the category that I assigned them to

Attribute Category
accessory_material Shipping Containers (bi-13-3)
archery_target_type Archery Targets (sg-4-9-1-11-3)
arrow/bolt_material Arrows & Bolts (sg-4-9-1-5)
baby/toddler_equipment_safety_features Baby Toys & Activity Equipment (bt-5)
binocular/monocular_design Binoculars (co-3-1) & Monoculars (co-3-2)
book/file_cover_material Book Covers (os-1-1)
bottle_warmer/sterilizer_features Bottle Warmers & Sterilizers (bt-10-6)
bow_material Bows & Crossbows (sg-4-9-1-7)
cane_base_design Canes & Walking Sticks (hb-1-17-5-1)
chair/sofa_features Chairs (fr-7) & Sofas (fr-22)
changing_mat/tray_features Changing Mats & Trays (bt-9-4)
clay/slip_texture Clay & Modeling Dough (ae-2-1-2-12-1)
console_system Video Game Consoles (el-19)
cookware/bakeware_features Cookware & Bakeware (hg-11-2)
diaper_type Incontinence Aids (hb-1-11)
disposable/reusable_bag_features Pet Waste Bags (ap-2-44)
disposable/reusable_item_material Shipping Containers (bi-13-3)
door/frame_application Door Frames (ha-2-2-3)
fiber_optic_mode Fiber Optic Components (el-4-11)
hearing_aid_ear_side Hearing Aids (hb-1-10)
knitting/padding_project_type Crafting Fibers (ae-2-1-2-6)
lens/slide_material Optics (co-3)
mat/rug_shape Rugs (hg-3-57)
mat_base_material Yoga & Pilates Mats (sg-2-26-3)
mold/cut_shape Crafting Patterns & Molds (ae-2-1-6)
optical_drive_form_factor Optical Drives (el-7-9-14-6)
paint/dye_form Craft Paint, Ink & Glaze (ae-2-1-2-3)
paintball/airsoft_equipment_included Paintball (sg-4-9-10) & Airsoft (sg-4-9-7)
pet_apparel/bedding_features Pet Apparel (ap-2-6) & Pet Beds (ap-2-9)
pole/post_material Parasols & Rain Umbrellas (hg-16)
radio_case_design Radio Carrying Cases (el-4-3-2)
saddle_material Bicycle Saddles (sg-4-4-2-13)
timepiece_features Watches (aa-6-11)
toilet/bidet_mounting_type Toilets & Bidets (ha-10-3-6)
transfer_aid_type Transfer Boards & Sheets (hb-1-17-1-3)
vehicle_engine/part_features Vehicle Parts & Accessories (vp-1)
washer/dryer_features Laundry Appliances (hg-9-8)
watch/band_material Watch Bands (aa-6-10-1)
wipe_dispenser/warmer_features Baby Wipe Dispensers & Warmers (bt-9-1)

@hadijafar hadijafar changed the title Add orphan detection tests for attributes and categories Orphan detection for attributes and categories + linking orphans Jan 30, 2026
@hadijafar hadijafar force-pushed the orphan-tests-for-attributes-and-categories branch from e7e7b85 to 00697ea Compare February 2, 2026 15:51
@hadijafar
Copy link
Copy Markdown
Contributor Author

hadijafar commented Feb 2, 2026

Tried linking the orphans to correctly but not entirely sure if they all went to the right files. Will need to regenerate the taxonomy.json and categories.json if this looks good

Copy link
Copy Markdown
Collaborator

@danielpgross danielpgross left a comment

Choose a reason for hiding this comment

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

Code looks good overall 👍 left a few comments

As for fixing the orphans by adding them to categories, this is a content (not code) decision so we'll need approval from @ricardotejedorsanz. Considering that, it might be helpful to break this up into two PRs to keep up momentum: one for attributes and the other for return reasons.

Comment thread dev/test/integration/orphan_detection_test.rb Outdated
Comment thread dev/test/integration/orphan_detection_test.rb Outdated
@hadijafar hadijafar force-pushed the orphan-tests-for-attributes-and-categories branch from 00697ea to 6deba9d Compare February 3, 2026 18:51
@hadijafar hadijafar changed the title Orphan detection for attributes and categories + linking orphans Orphan detection for attributes + linking orphans Feb 3, 2026
@hadijafar hadijafar force-pushed the orphan-tests-for-attributes-and-categories branch 4 times, most recently from ea5459a to 473d426 Compare February 3, 2026 21:58
@hadijafar
Copy link
Copy Markdown
Contributor Author

return reasons are moved to this pr

Copy link
Copy Markdown
Collaborator

@danielpgross danielpgross left a comment

Choose a reason for hiding this comment

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

A few more comments, almost there

Comment thread dev/test/integration/orphan_detection_test.rb Outdated
Comment thread dev/test/integration/orphan_detection_test.rb Outdated
Comment thread dev/test/integration/orphan_detection_test.rb Outdated
@hadijafar hadijafar self-assigned this Feb 5, 2026
Copy link
Copy Markdown
Collaborator

@ricardotejedorsanz ricardotejedorsanz left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @hadijafar, great suggestions!

A couple of general comments:

  • Some attributes were added to parents but won't apply to all children, we tend to avoid this - e.g. paintball/airsoft_equipment_included in Airsoft, since this won't apply to categories like Airsoft Gun Batteries
  • Some attribute connections create duplication, generally because the attribute we're adding is the extended version of a base attribute or viceversa - e.g. pole/post_material vs pole_material in Parasols & Rain Umbrellas

Here's the list of changes I recommend SKIPPING/REJECTING:

Category Category Type Attribute Issue Comment
Airsoft parent paintball/airsoft_equipment_included Parent category with child-specific attributes We tend to avoid attributes at the parent that won't apply to the children; this ensures the right granularity applies at the category level
Arrows & Bolts parent arrow/bolt_material Duplicate Duplicates material
Binoculars leaf binocular/monocular_design Duplicate Duplicates binocular design (extended attribute)
Book Covers leaf book/file_cover_material Duplicate Duplicates book / cover material (extended attribute)
Chairs parent chair/sofa_features Duplicate Duplicates chair features (it is an extended attributes of it)
Door Frames leaf door/frame_application Duplicate Duplicates door/frame application (extended attribute)
Incontinence Aids parent diaper_type Parent category with child-specific attributes We tend to avoid attributes at the parent that won't apply to the children; this ensures the right granularity applies at the category level
Laundry Appliances parent washer/dryer_features Parent category with child-specific attributes We tend to avoid attributes at the parent that won't apply to the children; this ensures the right granularity applies at the category level
Monoculars leaf binocular/monocular_design Duplicate Duplicates monocular design (extended attribute)
Paintball parent paintball/airsoft_equipment_included Parent category with child-specific attributes We tend to avoid attributes at the parent that won't apply to the children; this ensures the right granularity applies at the category level
Parasols & Rain Umbrellas parent pole/post_material Duplicate Duplicates pole material (it is an extended attributes of it)
Pet Apparel parent pet_apparel/bedding_features Duplicate Duplicates pet/apparel features (it is an extended attributes of it)
Pet Beds parent pet_apparel/bedding_features Duplicate Duplicates pet/bedding features (it is an extended attributes of it)
Rugs leaf mat/rug_shape Duplicate Duplicates rug shape (extended attribute)
Shipping Containers leaf accessory_material Duplicate Duplicates material
Shipping Containers leaf disposable/reusable_item_material Duplicate Duplicates material
Sofas parent chair/sofa_features Duplicate Duplicates sofa features (it is an extended attributes of it)
Watch Bands leaf watch/band_material Duplicate Duplicates band material
Watches leaf timepiece_features Duplicate Duplicates watch features

@ricardotejedorsanz
Copy link
Copy Markdown
Collaborator

ricardotejedorsanz commented Feb 9, 2026

Also @hadijafar let me know if you run into any conflicts you don't know how to solve while rebasing, we have merged quite a few changes to main recently 🙏

@hadijafar hadijafar force-pushed the orphan-tests-for-attributes-and-categories branch 3 times, most recently from a30dff3 to 43894fb Compare February 10, 2026 19:34
@hadijafar hadijafar force-pushed the orphan-tests-for-attributes-and-categories branch from 43894fb to 56b579a Compare February 10, 2026 20:17
@hadijafar hadijafar force-pushed the orphan-tests-for-attributes-and-categories branch from 56b579a to 0ff1347 Compare February 10, 2026 20:24
Copy link
Copy Markdown
Collaborator

@danielpgross danielpgross left a comment

Choose a reason for hiding this comment

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

Code changes look good 👍

Copy link
Copy Markdown
Collaborator

@ricardotejedorsanz ricardotejedorsanz left a comment

Choose a reason for hiding this comment

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

Reviewed the final mappings, everything looks good. Thanks @hadijafar !

@hadijafar
Copy link
Copy Markdown
Contributor Author

hadijafar commented Mar 12, 2026

these 4 were removed in 46ae1d3

Attribute Category Why
fuel_compatibility Fireplace & Wood Stove Grates (hg-5-2) The attribute describes which fuel types the grate supports; this is directly relevant and not duplicated by another existing attribute on the category.
bag_insulation Wine Carrier Bags (hg-11-3-12) The attribute description explicitly refers to whether a wine carrier bag is insulated. It seems it was previously assigned to Can & Bottle Sleeves, but Wine Carrier Bags is the more accurate fit.
insulation_status Canteens (hg-11-3-2) The attribute description explicitly refers to canteens. It appears to have been previously misassigned to Can & Bottle Sleeves.
sleeve_insulation Can & Bottle Sleeves (hg-11-3-4-1) This one appears correctly scoped to sleeves and should belong here.

Unsure orphans

These appear to be duplicates or near-duplicates of attributes already present on the relevant categories, which matches the same review logic already applied elsewhere in this PR:

Attribute Suggested category mapping Notes
topographical_relief Globe leaf categories under hg-3-75 These categories currently use relief_style. If we want topographical_relief, I think it should probably replace relief_style rather than be added alongside it.
grater_design Food Zesters (hg-11-8-30-2) and possibly Food Graters & Zesters (hg-11-8-30) This one looks like the clearest true re-link. Food Graters already uses food_grater_type, but Food Zesters currently has no equivalent design/type attribute.
bakeware_features Bakeware categories under hg-11-2-1* These currently use cookware/bakeware_features. If we want to link bakeware_features, I think it should replace that shared attribute on bakeware categories rather than be added next to it.
cookware_features Cookware categories under hg-11-2-3* Same idea as above: these currently use cookware/bakeware_features, so cookware_features feels more appropriate for cookware if used as a replacement, not an addition.
bakeware_pieces_included Bakeware Sets (hg-11-2-1-1) and maybe Cookware & Bakeware Combo Sets (hg-11-2-4) These categories currently use bakeware_items_included. This seems linkable, but likely as a replacement rather than a second overlapping set-contents attribute.
cookware_coating_material Coated cookware categories, especially Frying Pans (hg-11-2-3-13-1) / Skillets (hg-11-2-3-13-2) These currently use cookware_coating_type. If we want this attribute linked, I think it should probably replace that field where material is the more accurate model.
wax_paper_form Wax Paper (hg-11-4-7-4) This category currently uses wrap_format. wax_paper_form seems like a more product-specific version, but I’d use it as a replacement rather than add both.
wax_paper_form wrap_format wrap_format already covers rolls/sheets and is broader.

@hadijafar hadijafar merged commit 2a91d47 into main Mar 12, 2026
7 checks passed
@hadijafar hadijafar deleted the orphan-tests-for-attributes-and-categories branch March 12, 2026 18:11
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.

3 participants