LCFS - Extract reusable PaginatedQueryBuilder to eliminate duplication
- Dominant language
- Python
- Stars
- 6
- Forks
- 6
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 87
Description
**Describe the task**
Create a reusable `PaginatedQueryBuilder` class to replace the duplicated pagination, filtering, and sorting logic found across 37 repository files.
**Purpose**
Almost every repository independently implements the same pattern: iterating over `pagination.filters`, mapping fields, and applying filter conditions. This duplication increases maintenance burden and makes it easy for pagination behavior to diverge between endpoints.
**Acceptance Criteria**
- [ ] Create a `PaginatedQueryBuilder` that handles common filter/sort/paginate logic
- [ ] Migrate at least 2 high-traffic repositories to use the new builder
- [ ] Verify that existing pagination behavior is preserved (same results, same API contracts)
- [ ] Document the builder's API for use in remaining repositories
- [ ] All existing tests pass after migration
**Additional context**
- Base functionality exists in `backend/lcfs/web/api/base.py` but isn't used consistently
- Affected repos include: organizations, transactions, compliance_report, fuel_code, charging_site, and 32+ others
- Each repo has a `get_.*paginated` method with near-identical filter/sort boilerplate
Contributor guide
Assessment
This issue has not been assessed yet.