fix(sets): cleaup of code for set refresh

This commit is contained in:
FrederikBaerentsen
2025-12-24 08:28:36 -05:00
parent 5418aca8f0
commit 4336ad4de3
3 changed files with 9 additions and 31 deletions

View File

@@ -2,6 +2,15 @@
## 1.4
### Bug Fixes
- **Fixed set refresh functionality**: Resolved issues with refreshing sets from Rebrickable
- Fixed foreign key constraint errors during refresh by reusing existing set IDs instead of generating new UUIDs
- Implemented UPDATE-then-INSERT pattern to properly update existing parts while preserving user tracking data
- Part quantities now correctly sync with Rebrickable during refresh
- User tracking data (`checked`, `missing`, `damaged`) is now preserved across refreshes
- New parts from Rebrickable are added to local inventory during refresh
### New Features
- **Export Functionality**

View File

@@ -23,7 +23,6 @@ class BrickPart(RebrickablePart):
# Queries
insert_query: str = 'part/insert'
upsert_query: str = 'part/upsert'
update_on_refresh_query: str = 'part/update_on_refresh'
generic_query: str = 'part/select/generic'
select_query: str = 'part/select/specific'

View File

@@ -1,30 +0,0 @@
INSERT INTO "bricktracker_parts" (
"id",
"figure",
"part",
"color",
"spare",
"quantity",
"element",
"rebrickable_inventory",
"checked",
"missing",
"damaged"
) VALUES (
:id,
:figure,
:part,
:color,
:spare,
:quantity,
:element,
:rebrickable_inventory,
0,
0,
0
)
ON CONFLICT("id", "figure", "part", "color", "spare")
DO UPDATE SET
"quantity" = excluded."quantity",
"element" = excluded."element",
"rebrickable_inventory" = excluded."rebrickable_inventory"