Replace 'recently refreshed' sort with 'most recent episode' in feed list
All checks were successful
Build and push Docker image / build (push) Successful in 12s
Test / test (push) Successful in 15s

Annotates feed queryset with Max(episodes__pub_date) so feeds are sorted
by when their latest episode was published, not when the feed was last fetched.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marwin Schulz 2026-03-20 09:07:01 +01:00
parent 92801c9bbf
commit afcbe087bb
3 changed files with 7 additions and 4 deletions

View file

@ -5,7 +5,7 @@ import xml.etree.ElementTree as ET
import feedparser
import requests
from django.conf import settings
from django.db.models import Count, F, Q
from django.db.models import Count, F, Max, Q
from django.http import JsonResponse
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
@ -176,7 +176,8 @@ def feed_list(request):
feeds = list(
request.user.podcast_feeds
.values('id', 'title', 'artwork_url', 'rss_url', 'last_refreshed_at', 'author', 'added_at', 'auto_queue')
.annotate(latest_episode_at=Max('episodes__pub_date'))
.values('id', 'title', 'artwork_url', 'rss_url', 'last_refreshed_at', 'author', 'added_at', 'auto_queue', 'latest_episode_at')
)
for f in feeds:
@ -184,6 +185,8 @@ def feed_list(request):
f['last_refreshed_at'] = f['last_refreshed_at'].isoformat()
if f['added_at']:
f['added_at'] = f['added_at'].isoformat()
if f['latest_episode_at']:
f['latest_episode_at'] = f['latest_episode_at'].isoformat()
return JsonResponse({'feeds': feeds})

View file

@ -1193,7 +1193,7 @@ function sortFeeds(order) {
if (order === 'alpha') podcastFeeds.sort((a, b) => a.title.localeCompare(b.title));
if (order === 'alpha-desc') podcastFeeds.sort((a, b) => b.title.localeCompare(a.title));
if (order === 'added') podcastFeeds.sort((a, b) => (b.added_at || '').localeCompare(a.added_at || ''));
if (order === 'refreshed') podcastFeeds.sort((a, b) => (b.last_refreshed_at || '').localeCompare(a.last_refreshed_at || ''));
if (order === 'latest_episode') podcastFeeds.sort((a, b) => (b.latest_episode_at || '').localeCompare(a.latest_episode_at || ''));
renderFeedList();
}

View file

@ -256,7 +256,7 @@
<option value="alpha">AZ</option>
<option value="alpha-desc">ZA</option>
<option value="added">Recently added</option>
<option value="refreshed">Recently refreshed</option>
<option value="latest_episode">Most recent episode</option>
</select>
</div>
<div id="podcast-feed-list" class="podcast-feed-list">