Skip to content

Commit

Permalink
Report download bug (#740)
Browse files Browse the repository at this point in the history
* Update report download logic to include all quiz completions for the user bureaus when user selects agency only

* removed unused import
  • Loading branch information
felder101 authored Jan 21, 2025
1 parent c995e29 commit d9a3cac
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion training/repositories/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ def get_user_quiz_completion_report(self, filter: SmartPayTrainingReportFilter,
if filter.bureau_id is not None:
query = query.filter(models.User.agency_id == filter.bureau_id)
elif filter.agency_id is not None:
query = query.filter(models.User.agency_id == filter.agency_id)
# if agency is selected and not the bureau, return all records associated to agency/bureau the user has access to
all_agencies = self._session.query(models.Agency).all()
selected_agency = [agency for agency in all_agencies if agency.id == filter.agency_id][0]
selected_agency_bureaus_ids = [agency.id for agency in all_agencies if agency.name == selected_agency.name]
allowed_agency_ids = [obj.id for obj in report_user.report_agencies]
filter_agencies = [x for x in allowed_agency_ids if x in selected_agency_bureaus_ids]
query = query.filter(models.User.agency_id.in_(filter_agencies))
else:
allowed_agency_ids = [obj.id for obj in report_user.report_agencies]
query = query.filter(models.User.agency_id.in_(allowed_agency_ids))
Expand Down

0 comments on commit d9a3cac

Please sign in to comment.