Skip to content

Commit

Permalink
merge consecutive save calls in the workflow methods
Browse files Browse the repository at this point in the history
  • Loading branch information
osoukup committed Jan 10, 2025
1 parent 9928e96 commit 2ef9756
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"filename": "apps/workflows/tests/test_endpoints.py",
"hashed_secret": "3c3b274d119ff5a5ec6c1e215c1cb794d9973ac1",
"is_verified": false,
"line_number": 283,
"line_number": 280,
"is_secret": false
}
],
Expand Down Expand Up @@ -449,5 +449,5 @@
}
]
},
"generated_at": "2025-01-06T14:40:43Z"
"generated_at": "2025-01-10T11:24:13Z"
}
4 changes: 0 additions & 4 deletions apps/workflows/tests/test_endpoints.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from datetime import datetime

import pytest
from django.conf import settings
from freezegun import freeze_time

from apps.taskman.service import JiraTaskmanQuerier
from apps.workflows.models import State, Workflow
Expand Down Expand Up @@ -429,7 +426,6 @@ class TestFlawDraft:
def mock_create_task(self, flaw):
return "OSIM-123"

@freeze_time(datetime(2020, 12, 12)) # freeze against top of the second crossing
@pytest.mark.vcr
def test_promote(
self,
Expand Down
26 changes: 12 additions & 14 deletions apps/workflows/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,12 @@ def promote(self, save=True, jira_token=None, **kwargs):

self.workflow_state = state_obj.name

if not save:
return

# keep the save to Jira and BZ separate because BZ can be done asynchronously
# (Jira token is passed directly, but BZ token is in kwargs)
self.save(jira_token=jira_token, raise_validation_error=False)
self.save(raise_validation_error=False, **kwargs)
if save:
self.save(
jira_token=jira_token,
raise_validation_error=False,
**kwargs,
)

def reject(self, save=True, jira_token=None, **kwargs):
"""
Expand All @@ -306,13 +305,12 @@ def reject(self, save=True, jira_token=None, **kwargs):
self.workflow_name = reject_workflow
self.workflow_state = WorkflowModel.WorkflowState.REJECTED

if not save:
return

# keep the save to Jira and BZ separate because BZ can be done asynchronously
# (Jira token is passed directly, but BZ token is in kwargs)
self.save(jira_token=jira_token, raise_validation_error=False)
self.save(raise_validation_error=False, **kwargs)
if save:
self.save(
jira_token=jira_token,
raise_validation_error=False,
**kwargs,
)

def jira_status(self):
return WorkflowFramework().jira_status(self)
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Moved docker-compose images from docker.io to mirror.gcr.io (OSIDB-3653)
- Removed `last_validated_dt` from exposed JSON Flaw History data (OSIDB-3814)
- Fix workflow mid-air collisions (OSIDB-3842)

## [4.6.3] - 2025-01-09
### Fixed
Expand Down

0 comments on commit 2ef9756

Please sign in to comment.