Members form performance issue

Created on 3 June 2025, 3 days ago

Problem/Motivation

The LearningPathMembersForm class in the Opigno LMS module fetches all group content entities for the learning_path group bundle without query-level pagination, loading them into memory before chunking the results in PHP. This approach is inefficient for learning paths with large numbers of members (e.g., 1000+), leading to high memory usage and slow page loads. The goal is to improve performance by implementing query-level pagination to load only the necessary subset of group content.

Steps to reproduce

1. Create a learning path with a large number of members (e.g., 1000+ users and/or classes).
2. Navigate to the group members page (/group/{group}/members) for the learning path.
3. Observe slow page load times and high memory usage, especially with large datasets, due to loading all group content entities before pagination.
4. Check the displayed member count in the "Learners not in a class" section, which may not accurately reflect only users not in classes.

Proposed resolution

Implement query-level pagination in the buildForm method of LearningPathMembersForm for the learning_path group bundle:
- Add a count query to determine the total number of group content items.
- Use range($offset, $per_page) in the entity query to load only the current page’s group content.
- Initialize the pager with the total count to ensure correct navigation.
- Fix the member count display in the "Learners not in a class" table header to use count($individual_members) instead of the total group content count, ensuring it accurately reflects users not in classes.
The patch maintains existing functionality for other group bundles (e.g., opigno_class) and ensures compatibility with AJAX pagination.

Remaining tasks

- Test the patch with small, medium, and large learning paths (e.g., 10, 100, 1000+ members) to verify performance improvements.
- Test AJAX pagination to ensure seamless page navigation.
- Verify the corrected member count display in the "Learners not in a class" section.
- Perform regression testing for opigno_class group bundles and non-paginated views.
- Review compatibility with the target Drupal version (e.g., Drupal 9/10) and Opigno LMS.
- Submit the patch to the Opigno LMS issue queue with performance benchmarks and test results.

User interface changes

- No intentional UI changes, as the form structure and rendering remain unchanged.
- The member count in the "Learners not in a class" table header is corrected to accurately reflect only users not in classes, improving clarity.
- Pagination behavior remains consistent, with improved performance for large datasets.

API changes

No API changes. The patch modifies internal logic in LearningPathMembersForm::buildForm without altering public methods, routes, or interfaces.

Data model changes

No data model changes. The patch optimizes the entity query without modifying the underlying group content or user data structures.

✨ Feature request
Status

Active

Version

3.2

Component

Code

Created by

🇬🇧United Kingdom marcif

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024