Added sort by remaining weight
This commit is contained in:
@@ -139,7 +139,12 @@ async def find(
|
|||||||
|
|
||||||
if sort_by is not None:
|
if sort_by is not None:
|
||||||
for fieldstr, order in sort_by.items():
|
for fieldstr, order in sort_by.items():
|
||||||
|
if fieldstr == "remaining_weight":
|
||||||
|
stmt = stmt.add_columns((models.Filament.weight - models.Spool.used_weight).label("remaining_weight"))
|
||||||
|
field = sqlalchemy.column("remaining_weight")
|
||||||
|
else:
|
||||||
field = parse_nested_field(models.Spool, fieldstr)
|
field = parse_nested_field(models.Spool, fieldstr)
|
||||||
|
|
||||||
if order == SortOrder.ASC:
|
if order == SortOrder.ASC:
|
||||||
stmt = stmt.order_by(field.asc())
|
stmt = stmt.order_by(field.asc())
|
||||||
elif order == SortOrder.DESC:
|
elif order == SortOrder.DESC:
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ def test_find_all_spools_limit_asc_offset_outside_range(spools: Fixture): # noq
|
|||||||
"last_used",
|
"last_used",
|
||||||
"filament_id",
|
"filament_id",
|
||||||
"used_weight",
|
"used_weight",
|
||||||
|
"remaining_weight",
|
||||||
"location",
|
"location",
|
||||||
"lot_nr",
|
"lot_nr",
|
||||||
"comment",
|
"comment",
|
||||||
|
|||||||
Reference in New Issue
Block a user