in backend/bms_app/wave/services/waves.py [0:0]
def add_aggregated_db_status(wave_mappings_data):
"""Add calculated db status based on statuses of targtes.
Compare statuses from the db and to predifined ordered list.
That list is organized in the order in which stasuses can change.
So the 1-st found status can be treated as status of the operation.
"""
for db_id in wave_mappings_data:
all_statuses = [
x['operation_status'] for x in wave_mappings_data[db_id]['bms']
]
status = ''
for st_option in OPERATION_STATUSES_ORDER:
if st_option.value in all_statuses:
status = st_option.value
break
wave_mappings_data[db_id]['operation_status'] = status