Group uploaded letters by day of printing

Some teams have started uploading quite a lot of letters (in the
hundreds per week). They’re also uploading CSVs of emails. This means
the uploads page ends up quite jumbled.

This is because:
- there’s just a lot of items to scan through
- conceptually it’s a bit odd to have batches of things displayed
  alongside individual things on the same page

So instead this commit starts grouping together uploaded letters. It
does this by the date on which we ‘start’ printing them, or in other
words the time at which they can no longer be cancelled.

This feels like a natural grouping, and it matches what we know about
people’s mental models of ‘batches’ and ‘runs’ when talking about
printing.

The code for this is a bit gnarly because:
- timezones
- the print cutoff doesn’t align with the end of a day
- we have to do this in SQL because it wouldn’t be efficient to query
  thousands of letters and then do the timezone calculations on them in
  Python
This commit is contained in:
Chris Hill-Scott
2020-05-11 10:51:33 +01:00
parent 79646f7b4a
commit 421c1aac96
4 changed files with 179 additions and 99 deletions

View File

@@ -61,7 +61,7 @@ def get_paginated_uploads(service_id, limit_days, page):
upload_dict['statistics'] = [{'status': statistic.status, 'count': statistic.count} for statistic in
statistics]
else:
upload_dict['statistics'] = [{'status': upload.status, 'count': 1}]
upload_dict['statistics'] = []
data.append(upload_dict)
return {