Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scheduled Aggregate Report naming #3748

Merged
merged 18 commits into from
Nov 1, 2024
Merged

Conversation

madelondohmen
Copy link
Contributor

@madelondohmen madelondohmen commented Oct 29, 2024

NOTE: This PR uses the code of PR #3726

Changes

This PR fixes the bug where a scheduled Aggregate Report would always be generated with the name "Concatenated Report".

I've moved the "save_report" function out of SaveAggregateReportMixin and called it "save_aggregate_report_data". This way, it's possible to access the data from outside of the class.

I've given the SaveAggregateReportView a "report_type = AggregateOrganisationReport" and I've given the ReportRecipe model a "parent_report_type". This parent_report_type can be "concatinated-report", "aggregated-report" or None (for a single report).

Then in the ReportRunner it checks if the parent_report_type of the ReportRecipe is an Aggregate Report. If it is, it does a save_aggregate_report_data, else it does a save_report_data (for single or concatenated reports).

Issue link

Closes #3725

Demo

These schedules:
afbeelding

Result in:
afbeelding

QA notes

  • Create a scheduled Aggregate Report with "{report type}" in the name
  • Change the cron to * * * * * (go to the Scheduled Reports page, open the row, click on the edit button)
  • Go back to the Reports History page and refresh until the report is generated
  • You should see "Aggregate Report" in the name

Code Checklist

  • All the commits in this PR are properly PGP-signed and verified.
  • This PR only contains functionality relevant to the issue.
  • I have written unit tests for the changes or fixes I made.
  • I have checked the documentation and made changes where necessary.
  • I have performed a self-review of my code and refactored it to the best of my abilities.
  • Tickets have been created for newly discovered issues.
  • For any non-trivial functionality, I have added integration and/or end-to-end tests.
  • I have informed others of any required .env changes files if required and changed the .env-dist accordingly.
  • I have included comments in the code to elaborate on what is not self-evident from the code itself, including references to issues and discussions online, or implicit behavior of an interface.

Checklist for code reviewers:

Copy-paste the checklist from the docs/source/templates folder into your comment.


Checklist for QA:

Copy-paste the checklist from the docs/source/templates folder into your comment.

@madelondohmen madelondohmen marked this pull request as ready for review October 29, 2024 10:49
@madelondohmen madelondohmen requested a review from a team as a code owner October 29, 2024 10:49
rocky/reports/views/base.py Outdated Show resolved Hide resolved
@stephanie0x00
Copy link
Contributor

stephanie0x00 commented Oct 31, 2024

Checklist for QA:

  • I have checked out this branch, and successfully ran a fresh make reset.
  • I confirmed that there are no unintended functional regressions in this branch:
    • I have managed to pass the onboarding flow
    • Objects and Findings are created properly
    • Tasks are created and completed properly
  • I confirmed that the PR's advertised feature or hotfix works as intended.
  • I checked the logs for errors and/or warnings and made issues where necessary

What works:

Looks good, the bug is indeed fixed now.

What doesn't work:

n/a

Bug or feature?:

  • Discussed together that the label for aggregate reports is slightly confusing as it's not easy to reproduce what the aggregate report consists of.
  • Subreports are not available for an aggregate report.

The following screenshot to elaborate both above points:

image

Copy link

sonarcloud bot commented Nov 1, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
46.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@underdarknl underdarknl merged commit 1f42bae into main Nov 1, 2024
32 of 34 checks passed
@underdarknl underdarknl deleted the fix/aggregate-report-name branch November 1, 2024 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Aggregate Report is not included in ReportRecipe
5 participants