Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Return contributor details from list API and include in CSV download #1005

Merged
merged 4 commits into from Mar 30, 2020

Conversation

jwalgran
Copy link
Contributor

@jwalgran jwalgran commented Mar 27, 2020

Overview

Return contributor details from list API and include in CSV download.

Connects #997

Demo

2020-03-27 12 50 35

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

  • Run ./scripts/resetdb
  • Log in as c1@example.com
  • Browse http://localhost:8081/admin/api/contributor/5/ and delete the contributor.
  • Browse http://localhost:6543/ and open the Network tab in dev tools.
  • Click the "Facilities" tab and "Download CSV." Verify that request are made with a pageSize of 50 and that the final CSV can be saved without error.
  • Verify that the CSV contains records with empty, one, and multiple contributors in the new "contributors" column.

Checklist

  • fixup! commits have been squashed
  • CI passes after rebase
  • CHANGELOG.md updated with summary of features or fixes, following Keep a Changelog guidelines

@rajadain
Copy link
Contributor

Taking a look now.

Copy link
Contributor

@rajadain rajadain left a 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
Copy link
Contributor

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

?

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Contributor Author

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.

@rajadain rajadain assigned jwalgran and unassigned rajadain Mar 30, 2020
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.
@jwalgran jwalgran force-pushed the feature/jcw/download-affilations branch from 1853ac6 to 0ade4fb Compare March 30, 2020 17:45
@jwalgran
Copy link
Contributor Author

Thanks for the review.

@jwalgran jwalgran merged commit 15838a9 into develop Mar 30, 2020
@jwalgran jwalgran deleted the feature/jcw/download-affilations branch March 30, 2020 17:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants