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