From ff024459cea2b5359c02e4e01e504f1a001e5d40 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 14 Nov 2022 22:01:38 -0500 Subject: [PATCH] A little quick code cleanup. --- .../spiffworkflow_backend/models/spec_reference.py | 14 ++++++++++++++ .../services/spec_file_service.py | 12 +----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/spec_reference.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/spec_reference.py index 816025ef..52564136 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/spec_reference.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/spec_reference.py @@ -47,6 +47,20 @@ class SpecReferenceCache(SpiffworkflowBaseDBModel): is_executable = db.Column(db.Boolean()) # either 'process' or 'decision' is_primary = db.Column(db.Boolean()) + @classmethod + def from_spec_reference(cls, ref): + return cls( + identifier=ref.identifier, + display_name=ref.display_name, + process_model_id=ref.process_model_id, + type=ref.type, + file_name=ref.file_name, + has_lanes=ref.has_lanes, + is_executable=ref.is_executable, + is_primary=ref.is_primary, + relative_path=ref.relative_path,) + + class SpecReferenceSchema(Schema): """FileSchema.""" diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/spec_file_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/spec_file_service.py index 9b9cb518..4029444f 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/spec_file_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/spec_file_service.py @@ -234,17 +234,7 @@ class SpecFileService(FileSystemService): def update_process_cache(ref: SpecReference) -> None: process_id_lookup = SpecReferenceCache.query.filter_by(identifier=ref.identifier).first() if process_id_lookup is None: - process_id_lookup = SpecReferenceCache( - identifier=ref.identifier, - display_name=ref.display_name, - process_model_id=ref.process_model_id, - type=ref.type, - file_name=ref.file_name, - has_lanes=ref.has_lanes, - is_executable=ref.is_executable, - is_primary=ref.is_primary, - relative_path=ref.relative_path, - ) + process_id_lookup = SpecReferenceCache.from_spec_reference(ref) db.session.add(process_id_lookup) else: if ref.relative_path != process_id_lookup.relative_path: