Fixing presentation of objective thread
This commit is contained in:
1 parent
3ebe9a0894
commit
392b79e801
4 files changed
+97
-1
No files matched your search
@@ -7,6 +7,7 @@ the parts of that type that fit the row's scope.
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.crud import attachment_point as attachment_point_crud
|
||||
from app.crud import augmented_part as augmented_part_crud
|
||||
from app.crud import fit as fit_crud
|
||||
from app.crud import part_type as part_type_crud
|
||||
@@ -14,6 +15,7 @@ from app.crud import scope_info as scope_info_crud
|
||||
from app.models.fit import FitLabel
|
||||
|
||||
SCOPE_TYPE_NAME = "Scope"
|
||||
OBJECTIVE_ATTACHMENT_POINT_NAME = "Objective"
|
||||
|
||||
# "exact" outranks "possible" when the same part fits a scope via several fits.
|
||||
_LABEL_RANK = {FitLabel.EXACT.value: 2, FitLabel.POSSIBLE.value: 1}
|
||||
@@ -43,6 +45,7 @@ async def build(
|
||||
{
|
||||
"scope": AugmentedPart,
|
||||
"info": ScopeInfo | None,
|
||||
"objective_attachment_point": AttachmentPoint | None,
|
||||
"cells": {part_type_id: [{"part": AugmentedPart, "label": str}]},
|
||||
},
|
||||
...,
|
||||
@@ -85,6 +88,13 @@ async def build(
|
||||
p.id: p for p in await augmented_part_crud.get_many(db, list(other_ids))
|
||||
}
|
||||
|
||||
objective_aps = {
|
||||
ap.augmented_part_id: ap
|
||||
for ap in await attachment_point_crud.list_by_augmented_parts_and_name(
|
||||
db, list(scope_ids), OBJECTIVE_ATTACHMENT_POINT_NAME
|
||||
)
|
||||
}
|
||||
|
||||
infos = {
|
||||
info.augmented_part_id: info
|
||||
for info in await scope_info_crud.list_by_augmented_parts(db, list(scope_ids))
|
||||
@@ -120,6 +130,7 @@ async def build(
|
||||
{
|
||||
"scope": scope,
|
||||
"info": infos.get(scope.id),
|
||||
"objective_attachment_point": objective_aps.get(scope.id),
|
||||
"cells": cells,
|
||||
}
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user