Added endpoints for getting list of materials, etc

This commit is contained in:
Donkie
2023-08-26 11:08:57 +02:00
parent 9d51ee49ed
commit 557ea82171
4 changed files with 171 additions and 2 deletions

View File

@@ -257,3 +257,23 @@ async def use_length(db: AsyncSession, spool_id: int, length: float) -> models.S
await db.commit()
return spool
async def find_locations(
*,
db: AsyncSession,
) -> list[str]:
"""Find a list of spool locations by searching for distinct values in the spool table."""
stmt = sqlalchemy.select(models.Spool.location).distinct()
rows = await db.execute(stmt)
return [row[0] for row in rows.all() if row[0] is not None]
async def find_lot_numbers(
*,
db: AsyncSession,
) -> list[str]:
"""Find a list of spool lot numbers by searching for distinct values in the spool table."""
stmt = sqlalchemy.select(models.Spool.lot_nr).distinct()
rows = await db.execute(stmt)
return [row[0] for row in rows.all() if row[0] is not None]