Podcasts: state/ ohne Shownotes in der Inbox
Seit die Shownotes content:encoded nehmen (bis 50 KB pro Folge), würde die eine Anfrage der Apps mit 200 Inbox-Folgen sehr groß. state/ lässt sie weg; die Apps holen sie pro Folge über episodes/<id>/. inbox/ für das Web liefert sie weiter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f4b8bcc891
commit
fd0a103fb2
2 changed files with 11 additions and 7 deletions
|
|
@ -227,6 +227,8 @@ class RefreshAllTests(TestCase):
|
|||
self.assertEqual([q['episode__id'] for q in data['queue']], [ep.id])
|
||||
self.assertEqual([e['id'] for e in data['inbox']], [ep.id])
|
||||
self.assertTrue(data['inbox'][0]['in_queue'])
|
||||
# Shownotes stay out of the one-request state (they can be large).
|
||||
self.assertNotIn('description', data['inbox'][0])
|
||||
self.assertEqual(data['settings'], {'enqueue_position': 'back', 'auto_queue_position': 'front'})
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -753,7 +753,7 @@ def podcast_state(request):
|
|||
return JsonResponse({
|
||||
'feeds': _feeds_data(request.user),
|
||||
'queue': _queue_data(request.user),
|
||||
'inbox': _inbox_data(request.user, 0, limit),
|
||||
'inbox': _inbox_data(request.user, 0, limit, with_description=False),
|
||||
'settings': {'enqueue_position': s.enqueue_position, 'auto_queue_position': s.auto_queue_position},
|
||||
'server_time': timezone.now().isoformat(),
|
||||
})
|
||||
|
|
@ -1018,7 +1018,13 @@ def inbox(request):
|
|||
return JsonResponse({'episodes': _inbox_data(request.user, offset, limit), 'offset': offset, 'limit': limit})
|
||||
|
||||
|
||||
def _inbox_data(user, offset, limit):
|
||||
def _inbox_data(user, offset, limit, with_description=True):
|
||||
"""Inbox episodes. Shownotes can be large (up to 50 KB each); the apps'
|
||||
state/ leaves them out and loads one episode's at a time."""
|
||||
fields = ['id', 'title', 'audio_url', 'duration_seconds', 'pub_date', 'artwork_url',
|
||||
'feed__id', 'feed__title', 'feed__artwork_url']
|
||||
if with_description:
|
||||
fields.insert(2, 'description')
|
||||
hidden_ids = set(
|
||||
EpisodeProgress.objects.filter(
|
||||
user=user,
|
||||
|
|
@ -1032,11 +1038,7 @@ def _inbox_data(user, offset, limit):
|
|||
.exclude(id__in=hidden_ids)
|
||||
.select_related('feed')
|
||||
.order_by('-pub_date')
|
||||
.values(
|
||||
'id', 'title', 'description', 'audio_url', 'duration_seconds',
|
||||
'pub_date', 'artwork_url',
|
||||
'feed__id', 'feed__title', 'feed__artwork_url',
|
||||
)[offset:offset + limit]
|
||||
.values(*fields)[offset:offset + limit]
|
||||
)
|
||||
|
||||
progress_map = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue