vibe-kanban
vibe-kanban copied to clipboard
feat: Order projects by most recently used (Vibe Kanban)
Summary
This PR updates the project listing to order projects from most to least recently used, improving discoverability of active projects.
Changes
- Modified
Project::find_all()incrates/db/src/models/project.rsto order projects by recent task activity - Uses a LEFT JOIN with a subquery that finds the maximum
task_attempts.updated_atper project - Projects with recent task activity appear first
- Projects without any task activity fall back to ordering by
created_at DESC
Implementation Details
The query uses:
LEFT JOIN (
SELECT t.project_id, MAX(ta.updated_at) as last_activity
FROM tasks t
INNER JOIN task_attempts ta ON ta.task_id = t.id
GROUP BY t.project_id
) activity ON activity.project_id = p.id
ORDER BY activity.last_activity DESC NULLS LAST, p.created_at DESC
This approach:
- Avoids direct GROUP BY on the main query which causes SQLx type inference issues
- Uses
NULLS LASTto ensure projects without activity appear after active ones - Preserves chronological ordering (newest first) for projects with no task attempts
This PR was written using Vibe Kanban
when merge? need it.