diff --git a/src/dispatch/cost_model/service.py b/src/dispatch/cost_model/service.py index 50568f68b79e..ae84a376800b 100644 --- a/src/dispatch/cost_model/service.py +++ b/src/dispatch/cost_model/service.py @@ -34,7 +34,7 @@ def get_default(*, db_session, project_id: int) -> CostModel: return ( db_session.query(CostModel) .filter(CostModel.project_id == project_id) - .order_by(CostModel.created_at.desc()) + .order_by(CostModel.created_at.asc()) .first() ) @@ -121,6 +121,8 @@ def update(*, db_session, cost_model_in: CostModelUpdate) -> CostModel: cost_model_in.updated_at if cost_model_in.updated_at else datetime.utcnow() ) + cost_model.updated_at = cost_model.created_at + # Update all recognized activities. Delete all removed activities. update_activities = [] delete_activities = [] @@ -132,7 +134,6 @@ def update(*, db_session, cost_model_in: CostModelUpdate) -> CostModel: update_activities.append((activity, activity_in)) cost_model_in.activities.pop(idx_in) updated = True - break if updated: continue