Skip to content

Commit

Permalink
Updated admin report download logic to include all quiz completions f…
Browse files Browse the repository at this point in the history
…or the user bureaus when admin selects agency only (#741)
  • Loading branch information
felder101 authored Jan 21, 2025
1 parent d9a3cac commit ffdb6d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion training/repositories/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ def get_admin_smartpay_training_report(self, filter: SmartPayTrainingReportFilte
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
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]
query = query.filter(models.User.agency_id.in_(selected_agency_bureaus_ids))

if filter.completion_date_start is not None:
query = query.filter(models.QuizCompletion.submit_ts >= filter.completion_date_start)
Expand Down

0 comments on commit ffdb6d7

Please sign in to comment.