b29a268b1d
- Move completed plan files to .plans/done/ - Move 18 open plan files to .plans/open/ - Update .gitignore to exclude .verified_plans temp file - Verified all 18 open plans still describe unimplemented issues
1.3 KiB
1.3 KiB
Issue #201: countArchived() Loads All Members into Memory
Problem
The MemberService::countArchived() method loads ALL members into memory just to count archived ones:
public function countArchived(): int {
$allMembers = $this->memberMapper->findAll(null, null, true);
return count(array_filter($allMembers, fn(Member $m) => $m->getDeletedAt() !== null));
}
This is extremely inefficient for large member databases.
Impact
- Memory exhaustion with large member counts
- Slow archive page loads
- N+1 query problem (sub-entities loaded unnecessarily)
Solution
Add a COUNT query to the mapper:
public function countArchived(): int {
$qb = $this->db->getQueryBuilder();
$qb->select($qb->createFunction('COUNT(*)'))
->from($this->getTableName())
->where($qb->expr()->isNull('deleted_at'));
// Add: where status = 'geloescht' or deleted_at IS NOT NULL
...
}
Alternatively, add a deleted_at IS NOT NULL check to the existing findAll() method and return only the count.
Tasks
- Add
MemberMapper::countArchived(): intusingSELECT COUNT(*) WHERE deleted_at IS NOT NULL - Update
MemberService::countArchived()to use the new mapper method - Verify the count matches the archive list page size
Labels
- bug
- backend
- priority:high
- performance