Discovery API not generating the proper enrollment count in tutor

I enabled the discovery plugin in my openedx tutor and it seems to be working properly. But here’s my problem.

In the api endpoint https://discovery.local.overhang.io/api/v1/courses/ it generates a response from the discovery with the courses on my instance. But the problem is the enrollment count is always 0. I refered to the course discovery code directly in its models.py and its field was like this:

 enrollment_count = models.IntegerField(
        null=True, blank=True, default=0, help_text=_('Total number of learners who have enrolled in this course')
    )
    recent_enrollment_count = models.IntegerField(
        null=True, blank=True, default=0, help_text=_(
            'Total number of learners who have enrolled in this course in the last 6 months'
        )
    )

and in the class Meta, there was something like this:

    def clean(self):
        # We need to populate the value with 0 - model blank and null definitions are to validate the admin form.
        if self.enrollment_count is None:
            self.enrollment_count = 0
        if self.recent_enrollment_count is None:
            self.recent_enrollment_count = 0

But on my LMS end, the courses number of enrollees are available by importing from common.djangoapps.student.models import CourseEnrollment and the code:

CourseEnrollment.objects.filter( course_id=course_overview.id, is_active=True ).count()

HOW CAN I GENERATE THE PROPER ENROLLMENT COUNT ON THE DISCOVERY API?

Hmm… It looks like the recent_enrollment_count is updated by the AnalyticsAPIDataLoader, which one of the many things updated by the refresh_course_metadata management command.

Running that management command is crucial to keeping Course Discovery operational unfortunately… and it looks like it this was fixed in Tutor a while back, but maybe something has broken since then? Is there anything in your tutor init logs that shows any errors related to this command?

See Installation steps