Skip to content

Commit

Permalink
Fixed spool price sorting not working
Browse files Browse the repository at this point in the history
Resolves #349
  • Loading branch information
Donkie committed May 20, 2024
1 parent 52c52bc commit ca545b7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion spoolman/database/spool.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async def get_by_id(db: AsyncSession, spool_id: int) -> models.Spool:
return spool


async def find( # noqa: C901
async def find( # noqa: C901, PLR0912
*,
db: AsyncSession,
filament_name: Optional[str] = None,
Expand Down Expand Up @@ -185,6 +185,8 @@ async def find( # noqa: C901
elif fieldstr == "filament.combined_name":
sorts.append(models.Vendor.name)
sorts.append(models.Filament.name)
elif fieldstr == "price":
sorts.append(coalesce(models.Spool.price, models.Filament.price))
else:
sorts.append(parse_nested_field(models.Spool, fieldstr))

Expand Down

0 comments on commit ca545b7

Please sign in to comment.