Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user's classification count to "me" endpoint #3146

Open
adammcmaster opened this issue Jun 28, 2019 · 3 comments
Open

Add user's classification count to "me" endpoint #3146

adammcmaster opened this issue Jun 28, 2019 · 3 comments

Comments

@adammcmaster
Copy link
Contributor

At the moment PFE and the mobile app have to iterate over all the user's projects to sum their classifications. For users who have taken part in a lot of projects that can mean quite a few requests to the API.

@camallen
Copy link
Contributor

This would entail adding a classifications_count to the user serializer and ensuring it's a private attribute via ME_ONLY_ATTRS https://github.com/zooniverse/Panoptes/blob/426f33c42916706a40c923ba02b319b563bca15b/app/serializers/user_serializer.rb#L7

Two options for implementation:

  1. we store this value in the db and update the user classifications_count value with a counter on classification submission (high db contention on this update, i.e. counter caches but could be helped by worker limiting)
  2. It would be heavily cached in redis and would wrap the UserSeenSubject count methods with a redis increment method on classification submission. https://github.com/zooniverse/Panoptes/blob/426f33c42916706a40c923ba02b319b563bca15b/app/models/user_seen_subject.rb#L16

I'd prefer the straight lookup option 1 but it comes with the issue of ensuring the counters run properly and without locking contention on the user record.

@eatyourgreens
Copy link
Contributor

PFE and the mobile app both show you your classification counts per project, along with a total over all projects, so the counts they request are going to need to be broken down per project anyway. We can change the page size on the project preference requests to make this faster.

@eatyourgreens
Copy link
Contributor

Maybe also a filter on the UPP request to ignore UPP with a zero count? The code for your project stats ribbon spends a lot of time filtering out the preferences with zero classifications ie. projects you’ve visited but not classified on. Stats would be a lot faster if those UPPs were not included in the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants