fix(database): fixed front page database query
This commit is contained in:
@@ -289,7 +289,9 @@ class BrickPartList(BrickRecordList[BrickPart]):
|
||||
if current_app.config['RANDOM']:
|
||||
order = 'RANDOM()'
|
||||
else:
|
||||
order = '"bricktracker_parts"."rowid" DESC'
|
||||
# Since bricktracker_parts has a composite primary key, it doesn't have a rowid
|
||||
# Order by id DESC (which are UUIDs with timestamps) to get recent parts
|
||||
order = '"combined"."id" DESC, "combined"."part" ASC'
|
||||
|
||||
context = {}
|
||||
if current_app.config.get('HIDE_SPARE_PARTS', False):
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
-- Delete orphaned parts (bricktracker_parts records without parent rebrickable_parts)
|
||||
|
||||
DELETE FROM bricktracker_parts
|
||||
WHERE rowid IN (
|
||||
SELECT bp.rowid
|
||||
WHERE (id, figure, part, color, spare) IN (
|
||||
SELECT bp.id, bp.figure, bp.part, bp.color, bp.spare
|
||||
FROM bricktracker_parts bp
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM rebrickable_parts rp WHERE rp.part = bp.part AND rp.color_id = bp.color
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
-- Delete parts that reference non-existent sets
|
||||
|
||||
DELETE FROM bricktracker_parts
|
||||
WHERE rowid IN (
|
||||
SELECT bp.rowid
|
||||
WHERE (id, figure, part, color, spare) IN (
|
||||
SELECT bp.id, bp.figure, bp.part, bp.color, bp.spare
|
||||
FROM bricktracker_parts bp
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM bricktracker_sets bs WHERE bs.id = bp.id
|
||||
|
||||
Reference in New Issue
Block a user