Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(refactoring): order plan step counts through the shared queue rules (#3298)

Raghav Chamadiyaae3daf457325
diff --git a/packages/core/src/repowise/core/persistence/crud/analysis/refactoring_opportunities.py b/packages/core/src/repowise/core/persistence/crud/analysis/refactoring_opportunities.py
index 89de64775..38895583b 100644
--- a/packages/core/src/repowise/core/persistence/crud/analysis/refactoring_opportunities.py
+++ b/packages/core/src/repowise/core/persistence/crud/analysis/refactoring_opportunities.py
@@ -623,10 +623,12 @@ async def refactoring_step_counts(
) -> list[tuple[str, int]]:
"""Each matching opportunity's id and step count, in *order*: one narrow read,
so a page of plans is located without decoding any details."""
+ from ....analysis.health.refactoring.serving import sort_keys
+
rows = await session.execute(
select(RefactoringOpportunity.opportunity_id, RefactoringOpportunity.step_count)
.where(*_opportunity_filters(repository_id, **filters))
- .order_by(*_order_by(order))
+ .order_by(*order_by(RefactoringOpportunity, sort_keys(order)))
)
return [(opportunity_id, int(steps or 0)) for opportunity_id, steps in rows.all()]