Page MenuHomePhabricator

When an editor is added to the course, number of editors in the course overview is not updated
Closed, ResolvedPublic

Description

The statistics on top of each program page is not updated with new editors enrolling into the program.

I joined the Test Program DH2 with my personal account, Toughpigs:

https://outreachdashboard.wmflabs.org/courses/WMF/Test_Program_DH2/overview

More than 12 hours later, it still says there are 0 editors. Toughpigs is currently listed on the Editors page.

As Toughpigs, I made some WP edits about an hour ago, and those are showing up correctly in the stats -- 15 edits.

editor count 1.png (1,233×618 px, 56 KB)

editor count 2.png (1,227×554 px, 46 KB)

Event Timeline

@DannyH: I've gotten a little behind with deploying updates to outreach dashboard, and the update process has been broken for 14 days. (There was a change in ores that broke the updates; I fixed it, but had forgotten to deploy to P&E dashboard after the fix.)

Updating the user count itself upon joining should be pretty easy.

The not updating at all thing is a separate bug that should be fixed as of now — I just deployed — which means it ought to show the new edits within an hour or so.

The most expedient place to intervene here would be https://github.com/WikiEducationFoundation/WikiEduDashboard/blob/master/app/controllers/self_enrollment_controller.rb#L90

Normally, the user count gets updated only as part of updating all the caches for a course, in Course#update_cache. However, for active courses, that can take a few seconds, so we don't want to do that within the request. The simplest solution might be to add a narrower method to just update the course user count (which would probably mean tweaking CourseCacheManager to expose update_user_count as a public method).

One better approach for the long term might be to take this opportunity to add an abstraction — something like a 'course enrollment manager' — that would take a course, a user, and a role, and handle the creation and destruction of CoursesUsers records as well as cache updates.

Okay, the new editor stats updated on https://outreachdashboard.wmflabs.org/courses/WMF/Test_Program_DH3/overview around twenty minutes later, which is reasonable. Is there anything else left on this ticket to fix?

The above info was based on the assumption that we wanted to have it updated the user count immediate... which ideally, it should.

I went ahead and did the change I outlined above. After the next deployment, user counts will be updated immediately when a new user joins.

Ragesoss claimed this task.

The change is live now; user count should updated immediately upon joining (although leaving a course does not yet do the same thing).