Skip to content

Commit

Permalink
chore: Update branch
Browse files Browse the repository at this point in the history
Updating branch and making sure all tests are OK.
  • Loading branch information
giovanni-guidini committed Sep 11, 2023
1 parent 66ab117 commit 03509a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions tasks/label_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ async def run_async(self, db_session, request_id, *args, **kwargs):
commit=label_analysis_request.head_commit.commitid,
),
)

if label_analysis_request.state_id == LabelAnalysisRequestState.FINISHED.db_id:
# Indicates that this request has been calculated already
# We might need to update the requested labels
return self._handle_larq_already_calculated(label_analysis_request)

try:
Expand Down Expand Up @@ -164,7 +167,7 @@ def _handle_larq_already_calculated(self, larq: LabelAnalysisRequest):
# This means we already calculated everything
# Except possibly the absent labels
log.info(
"Label analysis was request already calculated",
"Label analysis request was already calculated",
extra=dict(
request_id=larq.id,
external_id=larq.external_id,
Expand Down Expand Up @@ -192,10 +195,11 @@ def _handle_larq_already_calculated(self, larq: LabelAnalysisRequest):
commit_sha=larq.head_commit.commitid,
)
larq.result = result # Save the new result
return { **result, 'success': True }
# No requested labels mean we don't have to calculate again
return {**result, "success": True, "errors": []}
# No requested labels mean we don't have any new information
# So we don't need to calculate again
# This shouldn't actually happen
return { **larq.result, 'success': True }
return {**larq.result, "success": True, "errors": []}

Check warning on line 202 in tasks/label_analysis.py

View check run for this annotation

Codecov / codecov/patch

tasks/label_analysis.py#L202

Added line #L202 was not covered by tests

def _get_requested_labels(self, label_analysis_request: LabelAnalysisRequest):
if label_analysis_request.requested_labels:
Expand Down
2 changes: 1 addition & 1 deletion tasks/tests/unit/test_label_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ async def test_simple_call_without_requested_labels_then_with_requested_labels(
"present_report_labels": expected_present_report_labels,
"success": True,
"global_level_labels": [],
"errors": [],
}
assert larf.result == {
"absent_labels": expected_absent_labels,
Expand All @@ -526,7 +527,6 @@ async def test_simple_call_without_requested_labels_then_with_requested_labels(
}



@pytest.mark.asyncio
async def test_simple_call_with_requested_labels(
dbsession, mock_storage, mocker, sample_report_with_labels, mock_repo_provider
Expand Down

0 comments on commit 03509a2

Please sign in to comment.