WikiEducationFoundation / WikiEduDashboard

Wiki Education Foundation's Wikipedia course dashboard system
https://dashboard.wikiedu.org
MIT License
389 stars 628 forks source link

Query to fetch user uploads in UserProfilesController#stats is slow for users with many uploads #2460

Open ragesoss opened 5 years ago

ragesoss commented 5 years ago

Part of the query for user stats involves fetching the latest 20 uploads for that user. This is extremely slow for a user with lots and lots of uploads (eg, User:Pharos).

My guess is that it's because of the ordering, which makes it miss the index. Might be solveable by adding an index for the date of upload.

marklocklear commented 2 years ago

How can I reproduce this locally? Any way to copy user data/contributions to my local environment?

ragesoss commented 2 years ago

One way would be to create a course locally, and set the start and end dates very wide (eg, 2014 - 2022), then add 'Pharos' as a participant and do a data update.

You could perhaps get a more realistically full database by copying each of the courses that user has participated in: https://outreachdashboard.wmflabs.org/users/Pharos

I'm not sure the description is right, as this user doesn't actually have a large number of uploads personally. (The large upload number is from events he has led.) But in any case, the user stats route is very slow for this user.

marklocklear commented 2 years ago

I'm getting an "Internal Server Error" when trying to create a program. Any ideas? Here is what I am seeing in the console:

app/controllers/courses_controller.rb:33:in `create'
[2022-03-03 15:26:40.521 INFO ] Processing by ErrorsController#internal_server_error as JSON
[2022-03-03 15:26:40.522 INFO ] Parameters: {"course"=>{"title"=>"Locklear Inc", "description"=>"this is a test", "school"=>"UNC Pembroke", "term"=>"", "level"=>"", "subject"=>"", "expected_students"=>"0", "format"=>"", "start"=>"2022-01-02T00:00:00-05:00", "end"=>"2022-03-01T00:00:00-05:00", "timeline_start"=>nil, "timeline_end"=>nil, "home_wiki"=>{"language"=>"en", "project"=>"wikipedia"}, "day_exceptions"=>"", "weekdays"=>"0000000", "editingSyllabus"=>false, "training_library_slug"=>"students", "loading"=>true, "updates"=>{}, "wikis"=>[{"language"=>"en", "project"=>"wikipedia"}], "type"=>"BasicCourse"}, "error"=>{"course"=>{"title"=>"Locklear Inc", "description"=>"this is a test", "school"=>"UNC Pembroke", "term"=>"", "level"=>"", "subject"=>"", "expected_students"=>"0", "format"=>"", "start"=>"2022-01-02T00:00:00-05:00", "end"=>"2022-03-01T00:00:00-05:00", "timeline_start"=>nil, "timeline_end"=>nil, "home_wiki"=>{"language"=>"en", "project"=>"wikipedia"}, "day_exceptions"=>"", "weekdays"=>"0000000", "editingSyllabus"=>false, "training_library_slug"=>"students", "loading"=>true, "updates"=>{}, "wikis"=>[{"language"=>"en", "project"=>"wikipedia"}], "type"=>"BasicCourse"}}}
[2022-03-03 15:26:40.523 DEBUG] Rendering errors/internal_server_error.json.jbuilder
[2022-03-03 15:26:40.524 INFO ] Rendered errors/internal_server_error.json.jbuilder (Duration: 0.3ms | Allocations: 95)
[2022-03-03 15:26:40.524 INFO ] Completed 500 Internal Server Error in 2ms (Views: 1.0ms | ActiveRecord: 0.0ms | Allocations: 1134)
ragesoss commented 2 years ago

Hmm... Not sure. Is there more of the stacktrace above that?