Replace 'recently refreshed' sort with 'most recent episode' in feed list
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:
parent
92801c9bbf
commit
afcbe087bb
3 changed files with 7 additions and 4 deletions
|
|
@ -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})
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@
|
|||
<option value="alpha">A–Z</option>
|
||||
<option value="alpha-desc">Z–A</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">
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue