bcgov / bcgov/lcfs

LCFS - Extract shared VersioningQueryHelper mixin for latest-record filters

Closed
#4,087 0 comments 0 reactions 1 assignee Claimed by @prv-proton View on GitHub
Low python Tech Debt
Dominant language
Python
Stars
6
Forks
6
Avg merge
2d 4h
Merged PRs (30d)
87

Description

**Describe the task**
Multiple repositories independently implement "latest version" filtering logic. Extract a shared `VersioningQueryHelper` mixin or utility.

**Purpose**
The same pattern of filtering for the latest version of a record is duplicated across ChargingEquipment, ChargingSite, and FinalSupplyEquipment repositories with slightly different implementations, risking inconsistency.

**Acceptance Criteria**
- [ ] Create a shared `VersioningQueryHelper` mixin or utility class
- [ ] Refactor `ChargingEquipmentRepository._apply_latest_equipment_version_filter()` to use the mixin
- [ ] Refactor `ChargingSite.latest_charging_site_version_subquery()` to use the mixin
- [ ] Refactor `FinalSupplyEquipmentRepository._latest_equipment_versions_subquery()` to use the mixin
- [ ] All existing tests pass after refactoring

**Additional context**
- Files: `charging_equipment/repo.py`, `charging_site/` models, `final_supply_equipment/repo.py`
- Each implements a subquery pattern to find the latest version of versioned entities

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.