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