Return contributor details from list API and include in CSV download #1005
Conversation
Taking a look now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 tested, this looks great 👏
Confirmed that the download is just the filtered facilities. Also neat to see a real live authentic progress bar, more than a prop to ease the user. Great job updating the tests, and adding input validation for new contributors.
'name': source, | ||
} | ||
request = self.context.get('request') \ | ||
if self.context is not None else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be shortened to
if self.context else None
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use this construction a few places in models.py too. In general I tend to prefer to use explicit None
checks when I can to avoid type coercion ambiguity, like empty objects being falsey.
>>> if {'key': 1}:
... print('true')
...
true
>>> if {}:
... print('true')
...
>>>
} | ||
request = self.context.get('request') \ | ||
if self.context is not None else None | ||
user = request.user if request is not None else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An explicit None check is less helpful here, but I have opted to use the same construction for consistency.
The complex permission and visibility checks required make fetching contributor details for each facility slow, so we are cutting the maximum results per page from 500 to 50. Contributor names and list names can have commas, so we join them with a vertical bar in the CSV to make machine parsing of multiple contributors possible.
We are using the | character to separate contributors in CSV downloads so we want to prevent using that character in names of contributors or lists.
We know the total number of facilities so it is possible to show percent progress. We have opted for a linear progress bar rather than a circular one because it looks better in this situation where our progress jumps rather than smoothly increases.
1853ac6
to
0ade4fb
Compare
Thanks for the review. |
Overview
Return contributor details from list API and include in CSV download.
Connects #997
Demo
Notes
The complex permission and visibility checks required make fetching contributor details for each facility slow, so we are cutting the maximum results per page from 500 to 50.
Contributor names and list names can have commas, so we join them with a vertical bar in the CSV to make machine parsing of multiple contributors possible. We add validations that prevent contributors from including the vertical bar in their name or their list names.
We know the total number of facilities so it is possible to show percent progress. We have opted for a linear progress bar rather than a circular one because it looks better in this situation where our progress jumps rather than smoothly increases.
Testing Instructions
./scripts/resetdb
Checklist
fixup!
commits have been squashed