forked from FrederikBaerentsen/BrickTracker
Add missing order options for most of the new queries
This commit is contained in:
parent
57158f75c8
commit
0420af5f95
@ -11,6 +11,7 @@ if TYPE_CHECKING:
|
||||
# Lego minifigures
|
||||
class BrickMinifigureList(BrickRecordList[BrickMinifigure]):
|
||||
brickset: 'BrickSet | None'
|
||||
order: str
|
||||
|
||||
# Queries
|
||||
all_query: str = 'minifigure/list/all'
|
||||
@ -25,11 +26,14 @@ class BrickMinifigureList(BrickRecordList[BrickMinifigure]):
|
||||
# Placeholders
|
||||
self.brickset = None
|
||||
|
||||
# Store the order for this list
|
||||
self.order = current_app.config['MINIFIGURES_DEFAULT_ORDER'].value
|
||||
|
||||
# Load all minifigures
|
||||
def all(self, /) -> Self:
|
||||
for record in self.select(
|
||||
override_query=self.all_query,
|
||||
order=current_app.config['MINIFIGURES_DEFAULT_ORDER'].value
|
||||
order=self.order
|
||||
):
|
||||
minifigure = BrickMinifigure(record=record)
|
||||
|
||||
@ -62,9 +66,7 @@ class BrickMinifigureList(BrickRecordList[BrickMinifigure]):
|
||||
self.brickset = brickset
|
||||
|
||||
# Load the minifigures from the database
|
||||
for record in self.select(
|
||||
order=current_app.config['MINIFIGURES_DEFAULT_ORDER'].value
|
||||
):
|
||||
for record in self.select(order=self.order):
|
||||
minifigure = BrickMinifigure(brickset=self.brickset, record=record)
|
||||
|
||||
self.records.append(minifigure)
|
||||
@ -94,8 +96,11 @@ class BrickMinifigureList(BrickRecordList[BrickMinifigure]):
|
||||
self.fields.color_id = color_id
|
||||
self.fields.element_id = element_id
|
||||
|
||||
# Load the sets from the database
|
||||
for record in self.select(override_query=self.missing_part_query):
|
||||
# Load the minifigures from the database
|
||||
for record in self.select(
|
||||
override_query=self.missing_part_query,
|
||||
order=self.order
|
||||
):
|
||||
minifigure = BrickMinifigure(record=record)
|
||||
|
||||
self.records.append(minifigure)
|
||||
@ -115,8 +120,11 @@ class BrickMinifigureList(BrickRecordList[BrickMinifigure]):
|
||||
self.fields.color_id = color_id
|
||||
self.fields.element_id = element_id
|
||||
|
||||
# Load the sets from the database
|
||||
for record in self.select(override_query=self.using_part_query):
|
||||
# Load the minifigures from the database
|
||||
for record in self.select(
|
||||
override_query=self.using_part_query,
|
||||
order=self.order
|
||||
):
|
||||
minifigure = BrickMinifigure(record=record)
|
||||
|
||||
self.records.append(minifigure)
|
||||
|
@ -13,6 +13,7 @@ if TYPE_CHECKING:
|
||||
class BrickPartList(BrickRecordList[BrickPart]):
|
||||
brickset: 'BrickSet | None'
|
||||
minifigure: 'BrickMinifigure | None'
|
||||
order: str
|
||||
|
||||
# Queries
|
||||
all_query: str = 'part/list/all'
|
||||
@ -28,11 +29,14 @@ class BrickPartList(BrickRecordList[BrickPart]):
|
||||
self.brickset = None
|
||||
self.minifigure = None
|
||||
|
||||
# Store the order for this list
|
||||
self.order = current_app.config['PARTS_DEFAULT_ORDER'].value
|
||||
|
||||
# Load all parts
|
||||
def all(self, /) -> Self:
|
||||
for record in self.select(
|
||||
override_query=self.all_query,
|
||||
order=current_app.config['PARTS_DEFAULT_ORDER'].value
|
||||
order=self.order
|
||||
):
|
||||
part = BrickPart(record=record)
|
||||
|
||||
@ -52,9 +56,7 @@ class BrickPartList(BrickRecordList[BrickPart]):
|
||||
self.minifigure = minifigure
|
||||
|
||||
# Load the parts from the database
|
||||
for record in self.select(
|
||||
order=current_app.config['PARTS_DEFAULT_ORDER'].value
|
||||
):
|
||||
for record in self.select(order=self.order):
|
||||
part = BrickPart(
|
||||
brickset=self.brickset,
|
||||
minifigure=minifigure,
|
||||
@ -83,7 +85,7 @@ class BrickPartList(BrickRecordList[BrickPart]):
|
||||
# Load the parts from the database
|
||||
for record in self.select(
|
||||
override_query=self.minifigure_query,
|
||||
order=current_app.config['PARTS_DEFAULT_ORDER'].value
|
||||
order=self.order
|
||||
):
|
||||
part = BrickPart(
|
||||
minifigure=minifigure,
|
||||
@ -104,7 +106,7 @@ class BrickPartList(BrickRecordList[BrickPart]):
|
||||
def missing(self, /) -> Self:
|
||||
for record in self.select(
|
||||
override_query=self.missing_query,
|
||||
order=current_app.config['PARTS_DEFAULT_ORDER'].value
|
||||
order=self.order
|
||||
):
|
||||
part = BrickPart(record=record)
|
||||
|
||||
|
@ -9,6 +9,7 @@ from .set import BrickSet
|
||||
# All the sets from the database
|
||||
class BrickSetList(BrickRecordList[BrickSet]):
|
||||
themes: list[str]
|
||||
order: str
|
||||
|
||||
# Queries
|
||||
generic_query: str = 'set/list/generic'
|
||||
@ -24,14 +25,15 @@ class BrickSetList(BrickRecordList[BrickSet]):
|
||||
# Placeholders
|
||||
self.themes = []
|
||||
|
||||
# Store the order for this list
|
||||
self.order = current_app.config['SETS_DEFAULT_ORDER'].value
|
||||
|
||||
# All the sets
|
||||
def all(self, /) -> Self:
|
||||
themes = set()
|
||||
|
||||
# Load the sets from the database
|
||||
for record in self.select(
|
||||
order=current_app.config['SETS_DEFAULT_ORDER'].value
|
||||
):
|
||||
for record in self.select(order=self.order):
|
||||
brickset = BrickSet(record=record)
|
||||
|
||||
self.records.append(brickset)
|
||||
@ -45,7 +47,10 @@ class BrickSetList(BrickRecordList[BrickSet]):
|
||||
|
||||
# A generic list of the different sets
|
||||
def generic(self, /) -> Self:
|
||||
for record in self.select(override_query=self.generic_query):
|
||||
for record in self.select(
|
||||
override_query=self.generic_query,
|
||||
order=self.order
|
||||
):
|
||||
brickset = BrickSet(record=record)
|
||||
|
||||
self.records.append(brickset)
|
||||
@ -78,7 +83,8 @@ class BrickSetList(BrickRecordList[BrickSet]):
|
||||
|
||||
# Load the sets from the database
|
||||
for record in self.select(
|
||||
override_query=self.missing_minifigure_query
|
||||
override_query=self.missing_minifigure_query,
|
||||
order=self.order
|
||||
):
|
||||
brickset = BrickSet(record=record)
|
||||
|
||||
@ -100,7 +106,10 @@ class BrickSetList(BrickRecordList[BrickSet]):
|
||||
self.fields.element_id = element_id
|
||||
|
||||
# Load the sets from the database
|
||||
for record in self.select(override_query=self.missing_part_query):
|
||||
for record in self.select(
|
||||
override_query=self.missing_part_query,
|
||||
order=self.order
|
||||
):
|
||||
brickset = BrickSet(record=record)
|
||||
|
||||
self.records.append(brickset)
|
||||
@ -117,7 +126,10 @@ class BrickSetList(BrickRecordList[BrickSet]):
|
||||
self.fields.fig_num = fig_num
|
||||
|
||||
# Load the sets from the database
|
||||
for record in self.select(override_query=self.using_minifigure_query):
|
||||
for record in self.select(
|
||||
override_query=self.using_minifigure_query,
|
||||
order=self.order
|
||||
):
|
||||
brickset = BrickSet(record=record)
|
||||
|
||||
self.records.append(brickset)
|
||||
@ -138,7 +150,10 @@ class BrickSetList(BrickRecordList[BrickSet]):
|
||||
self.fields.element_id = element_id
|
||||
|
||||
# Load the sets from the database
|
||||
for record in self.select(override_query=self.using_part_query):
|
||||
for record in self.select(
|
||||
override_query=self.using_part_query,
|
||||
order=self.order
|
||||
):
|
||||
brickset = BrickSet(record=record)
|
||||
|
||||
self.records.append(brickset)
|
||||
|
Loading…
Reference in New Issue
Block a user