Adding top-level Scopes table
This commit is contained in:
1 parent
bc8b67d585
commit
3febc15a8f
11 files changed
+470
-1
No files matched your search
@@ -52,6 +52,29 @@ async def list_for_part(db: AsyncSession, augmented_part_id: int) -> list[Fit]:
|
||||
return list(result.scalars().all())
|
||||
|
||||
|
||||
async def list_for_parts(
|
||||
db: AsyncSession,
|
||||
part_ids: list[int],
|
||||
exclude_label: FitLabel | None = None,
|
||||
) -> list[Fit]:
|
||||
"""All fits touching any of the given augmented parts, in one query.
|
||||
|
||||
Pass ``exclude_label`` to drop, e.g., confirmed non-fits (``FitLabel.NONE``).
|
||||
"""
|
||||
if not part_ids:
|
||||
return []
|
||||
q = select(Fit).where(
|
||||
or_(
|
||||
Fit.augmented_part_a_id.in_(part_ids),
|
||||
Fit.augmented_part_b_id.in_(part_ids),
|
||||
)
|
||||
)
|
||||
if exclude_label is not None:
|
||||
q = q.where(Fit.label != exclude_label)
|
||||
result = await db.execute(q.order_by(Fit.id))
|
||||
return list(result.scalars().all())
|
||||
|
||||
|
||||
async def list_all(
|
||||
db: AsyncSession,
|
||||
skip: int = 0,
|
||||
|
||||
Reference in new issue
Block a user