Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/dve/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@

return processed_files, failed_processing

def apply_business_rules( # pylint: disable=R0914,R0915

Check failure on line 548 in src/dve/pipeline/pipeline.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=NHSDigital_data-validation-engine&issues=AaC1FeaJxXEneeMyvxbN&open=AaC1FeaJxXEneeMyvxbN&pullRequest=156
self, submission_info: SubmissionInfo, submission_status: Optional[SubmissionStatus] = None
) -> tuple[SubmissionInfo, SubmissionStatus]:
"""Apply the business rules to a given submission, the submission may have failed at the
Expand Down Expand Up @@ -894,18 +894,14 @@
.agg(pl.col("Count").sum()) # type: ignore
.iter_rows(named=True)
}
submission_rejections = err_types.get(
ErrorReportCategories.FILE_REJECTION.reporting_name, 0
)
sub_stats = SubmissionStatisticsRecord(
submission_id=submission_info.submission_id,
record_count=submission_status.number_of_records,
number_submission_rejections=submission_rejections,
number_record_rejections=(
submission_status.number_of_records
if submission_rejections > 0 else err_types.get( # type: ignore
ErrorReportCategories.RECORD_REJECTION.reporting_name, 0
)
number_submission_rejections=err_types.get(
ErrorReportCategories.FILE_REJECTION.reporting_name, 0
),
number_record_rejections=err_types.get(
ErrorReportCategories.RECORD_REJECTION.reporting_name, 0
),
number_warnings=err_types.get(ErrorReportCategories.WARNING.reporting_name, 0),
)
Expand Down
2 changes: 1 addition & 1 deletion tests/features/animals.feature
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ Feature: Pipeline tests using the animal dataset
| parameter | value |
| record_count | 7 |
| number_submission_rejections | 1 |
| number_record_rejections | 7 |
| number_record_rejections | 2 |
| number_warnings | 1 |
4 changes: 2 additions & 2 deletions tests/features/movies.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Feature: Pipeline tests using the movies dataset
| parameter | value |
| record_count | 5 |
| number_submission_rejections | 1 |
| number_record_rejections | 5 |
| number_record_rejections | 3 |
| number_warnings | 2 |
And the error aggregates are persisted

Expand Down Expand Up @@ -81,7 +81,7 @@ Feature: Pipeline tests using the movies dataset
| parameter | value |
| record_count | 5 |
| number_submission_rejections | 1 |
| number_record_rejections | 5 |
| number_record_rejections | 3 |
| number_warnings | 2 |
And the error aggregates are persisted

Loading