Problem
The years dropdown on the media index page is populated by LogbookQuery->years(), which returns years where items have "finished" events. This creates issues:
-
Incorrect years for backlog list - The backlog filters by media.created_at, but the dropdown shows years from finished events. If you added something to your backlog in 2015 but never finished anything that year, you can't filter to see it.
-
No year support for in-progress - Filters are disabled entirely for in-progress items.
-
Not responsive to type filter - If filtering by "book", the years dropdown still shows all years, not just years with books.
Current behavior
// MediaIndexController.php
private function years(): array
{
return (new LogbookQuery)->years();
}
This queries:
SELECT DISTINCT EXTRACT(year FROM media_events.occurred_at)
FROM media_event_types
JOIN media_events ON ...
WHERE media_event_types.name = 'finished'
Proposed solution
Replace the dynamic query with a static year range:
- Determine a start year (either hardcoded like
2018 or MIN(created_at) from media table)
- Generate range from start year to current year
- Use this same list for all lists (finished, backlog, in-progress)
Benefits
- Simpler code - remove
years() method from LogbookQuery
- Consistent behavior across all list types
- No per-request database query for years
- Works correctly regardless of which list or type filter is active
Trade-off
- Users might select a year with no results (shows "No items" - acceptable UX)
Files involved
app/Http/Controllers/MediaIndexController.php - years() method
app/Queries/Media/LogbookQuery.php - can remove years() method after
Problem
The years dropdown on the media index page is populated by
LogbookQuery->years(), which returns years where items have "finished" events. This creates issues:Incorrect years for backlog list - The backlog filters by
media.created_at, but the dropdown shows years from finished events. If you added something to your backlog in 2015 but never finished anything that year, you can't filter to see it.No year support for in-progress - Filters are disabled entirely for in-progress items.
Not responsive to type filter - If filtering by "book", the years dropdown still shows all years, not just years with books.
Current behavior
This queries:
Proposed solution
Replace the dynamic query with a static year range:
2018orMIN(created_at)from media table)Benefits
years()method from LogbookQueryTrade-off
Files involved
app/Http/Controllers/MediaIndexController.php-years()methodapp/Queries/Media/LogbookQuery.php- can removeyears()method after