From ed57993f8de21662aa14cbd7dfcce6abb8ec4832 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Tue, 31 Aug 2021 12:17:25 -0400 Subject: [PATCH] Workflow spec cleanup needs a category_id --- crc/api/workflow.py | 7 ++++--- crc/services/workflow_service.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crc/api/workflow.py b/crc/api/workflow.py index 44a99524..fb3f6a91 100644 --- a/crc/api/workflow.py +++ b/crc/api/workflow.py @@ -39,8 +39,9 @@ def all_specifications(libraries=False,standalone=False): def add_workflow_specification(body): - WorkflowService.cleanup_workflow_spec_display_order() - count = session.query(WorkflowSpecModel).filter_by(category_id=body['category_id']).count() + category_id = body['category_id'] + WorkflowService.cleanup_workflow_spec_display_order(category_id) + count = session.query(WorkflowSpecModel).filter_by(category_id=category_id).count() body['display_order'] = count new_spec: WorkflowSpecModel = WorkflowSpecModelSchema().load(body, session=session) session.add(new_spec) @@ -151,7 +152,7 @@ def delete_workflow_specification(spec_id): session.commit() # Reorder the remaining specs - WorkflowService.cleanup_workflow_spec_display_order() + WorkflowService.cleanup_workflow_spec_display_order(category_id) def reorder_workflow_specification(spec_id, direction): diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py index 8d3d7f55..8c84e488 100755 --- a/crc/services/workflow_service.py +++ b/crc/services/workflow_service.py @@ -987,10 +987,11 @@ class WorkflowService(object): return ordered_categories @staticmethod - def cleanup_workflow_spec_display_order(): + def cleanup_workflow_spec_display_order(category_id): # make sure we don't have gaps in display_order new_order = 0 specs = session.query(WorkflowSpecModel).\ + filter(WorkflowSpecModel.category_id == category_id).\ order_by(WorkflowSpecModel.display_order).all() for spec in specs: spec.display_order = new_order