WordPress / WordPress/Learn

Poor theme performance due to calling Sensei `get_courses_average_grade()`.

Open
#3,146 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

[Component] Learn Theme [Component] Sensei
Dominant language
PHP
Stars
333
Forks
127
Avg merge
1d 7h
Merged PRs (30d)
11

Description

The learn theme makes uncached calls to get_courses_average_grade() in the Course sidebar that causes a rather slow SQL query on certain pages.

This is mostly visible with courses that have been attempted by a lot of users.

Sensei code:
https://github.com/Automattic/sensei/blob/d1596603cd10e88260cd7f84831edcc9a137b203/includes/reports/overview/services/class-sensei-reports-overview-service-courses.php#L84-L108

We should ideally:

  • Cache the value on the post type (Either as postmeta, or in object cache)
  • Either calculate the average on a cron (postmeta), or update it upon course completion (postmeta, object cache + ondemand)
  • Switch to a stored Sensei meta value if one exists

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Learn theme's Course sidebar and the linked Sensei reports service at lines 84-108 to trace the uncached average-grade call. Determine whether Sensei already exposes a stored meta value, then choose and implement a caching or precomputation approach that removes the slow query on affected course pages. Done means the sidebar no longer makes the uncached call while still showing the course average.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.