|
|
|
@ -2091,15 +2091,15 @@ async def bulk_update_equipment(
|
|
|
|
calculation_data_id: UUID,
|
|
|
|
calculation_data_id: UUID,
|
|
|
|
):
|
|
|
|
):
|
|
|
|
# Create a dictionary mapping assetnum to is_included status
|
|
|
|
# Create a dictionary mapping assetnum to is_included status
|
|
|
|
case_mappings = {asset.assetnum: asset.is_included for asset in selected_equipments}
|
|
|
|
case_mappings = {asset.location_tag: asset.is_included for asset in selected_equipments}
|
|
|
|
|
|
|
|
|
|
|
|
# Get all assetnums that need to be updated
|
|
|
|
# Get all assetnums that need to be updated
|
|
|
|
assetnums = list(case_mappings.keys())
|
|
|
|
assetnums = list(case_mappings.keys())
|
|
|
|
|
|
|
|
|
|
|
|
# Create a list of when clauses for the case statement
|
|
|
|
# Create a list of when clauses for the case statement
|
|
|
|
when_clauses = [
|
|
|
|
when_clauses = [
|
|
|
|
(CalculationEquipmentResult.assetnum == assetnum, is_included)
|
|
|
|
(CalculationEquipmentResult.location_tag == location_tag, is_included)
|
|
|
|
for assetnum, is_included in case_mappings.items()
|
|
|
|
for location_tag, is_included in case_mappings.items()
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# Build the update statement
|
|
|
|
# Build the update statement
|
|
|
|
|