Skip to content

Adjust Size model and create SizeRangeSize for sizes_sizegroup join table#2679

Merged
pylipp merged 8 commits into
masterfrom
copilot/adjust-size-data-model
May 20, 2026
Merged

Adjust Size model and create SizeRangeSize for sizes_sizegroup join table#2679
pylipp merged 8 commits into
masterfrom
copilot/adjust-size-data-model

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 21, 2026

The DB migration in boxwise/dropapp#821 removes sizes.sizegroup_id and sizes.seq, replacing the direct FK with a new sizes_sizegroup cross-reference table. This PR updates the BE models and all query code to match.

Model changes

  • Size: removed seq and size_range (sizegroup_id FK) fields
  • SizeRangeSize (new): maps sizes_sizegroup with size_id → sizes and sizegroup_id → sizegroup, using CompositeKey("size", "size_range")
  • models/__init__.py: registers SizeRangeSize in MODELS

Query updates

All code that previously joined Size to SizeRange directly now routes through SizeRangeSize:

# Before: direct join on shared column (column no longer exists)
Product.select(...).left_outer_join(Size, on=(Product.size_range == Size.size_range))

# After: two-step lookup via join table
SizeRangeSize.select(SizeRangeSize, Size).join(Size)
# or for traversal queries:
Size.select(Size.id).join(SizeRangeSize).join(SizeRange).join(Product)

Affected files: loaders.py (SizesForSizeRangeLoader), warehouse/box/crud.py (bulk create), mobile_distribution/crud.py, cron/data_faking.py.

Test data

  • Removed size_range from size fixtures
  • Added size_range_size.py test data module; inserted into _NAMES ordering after size

@pylipp
Copy link
Copy Markdown
Contributor

pylipp commented Apr 21, 2026

@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.77%. Comparing base (20b8662) to head (0ed447e).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2679   +/-   ##
=======================================
  Coverage   76.76%   76.77%           
=======================================
  Files         301      302    +1     
  Lines       22266    22274    +8     
  Branches     2250     2249    -1     
=======================================
+ Hits        17093    17101    +8     
  Misses       5125     5125           
  Partials       48       48           
Flag Coverage Δ
backend 99.65% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the backend data model and query layer to align with the DB migration that replaces the sizes.sizegroup_id FK with a sizes_sizegroup join table, enabling many-to-many associations between sizes and size ranges.

Changes:

  • Removes obsolete columns from the Size model and introduces the SizeRangeSize join model.
  • Refactors loaders and business logic queries to traverse SizeRange ↔ Size via SizeRangeSize.
  • Updates test data setup and the minimal SQL seed to reflect the new schema.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
back/test/data/size.py Updates size fixture data to remove the old size_range FK field.
back/test/data/size_range_size.py Adds fixture data for the new sizes_sizegroup join table.
back/test/data/init.py Ensures join-table fixture creation runs in the correct dependency order.
back/test/auth0_integration_tests/test_operations.py Adjusts expected sizeRanges count after sizegroup changes.
back/minimal.sql Updates schema + seed data: drops old sizes columns and adds sizes_sizegroup table + data.
back/boxtribute_server/models/definitions/size.py Removes legacy fields from the Size Peewee model.
back/boxtribute_server/models/definitions/size_range_size.py Introduces the new Peewee model for sizes_sizegroup.
back/boxtribute_server/models/init.py Registers SizeRangeSize in the global model list.
back/boxtribute_server/graph_ql/loaders.py Refactors SizesForSizeRangeLoader to read sizes via the join table.
back/boxtribute_server/cron/data_faking.py Updates size lookup query to traverse via SizeRangeSize/SizeRange.
back/boxtribute_server/business_logic/warehouse/box/crud.py Refactors bulk-create sizing lookup to use SizeRangeSize mappings.
back/boxtribute_server/business_logic/mobile_distribution/crud.py Updates packing-list size selection query to use the join table path.

Comment thread back/boxtribute_server/business_logic/warehouse/box/crud.py Outdated
@pylipp pylipp marked this pull request as ready for review May 20, 2026 11:29
@pylipp
Copy link
Copy Markdown
Contributor

pylipp commented May 20, 2026

@pylipp pylipp merged commit 41a53ad into master May 20, 2026
12 of 14 checks passed
@pylipp pylipp deleted the copilot/adjust-size-data-model branch May 20, 2026 15:21
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