Skip to content

Instantly share code, notes, and snippets.

@nvlaarhoven
Last active December 13, 2022 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nvlaarhoven/41d4348e362d4764f7496cf9d02ca963 to your computer and use it in GitHub Desktop.
Save nvlaarhoven/41d4348e362d4764f7496cf9d02ca963 to your computer and use it in GitHub Desktop.
Being able to generate report with different comparison group
https://dabapps.mydonedone.com/issuetracker/projects/45387/issues/1470
// In order to let user regenerate a report with a different comparison group, we need to delete the `ReportGenerationBatch` from the database.
// The following worked because the report generation was on `manual` rather than `auto` and the activity only had `1` `ActivityProductVersion`
from project.assets.models.activities import Activity
activity = Activity.objects.get(id='f252ddd8-4f9c-4b0d-ad2e-698e74db6e79')
activity_product_version = activity.activity_product_version_items.get()
emails = ['michael.j.anderton@gmail.com', 'loader.mark1@gmail.com', 'paramoresimon@yahoo.co.uk']
activity_product_version.reportgenerationbatch_set.filter(session__user__email__in=emails).count()
// In this case there is exactly 1 `ReportGenerationBatch` for each user, so we can just delete these.
// If there was more than 1, more investigation would be needed
activity_product_version.reportgenerationbatch_set.filter(session__user__email__in=emails).delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment