From fd0a103fb245ab6909b48138e2e25725019fd5ec Mon Sep 17 00:00:00 2001 From: mrwnslz Date: Fri, 2 Oct 2026 08:01:34 +0200 Subject: [PATCH] Podcasts: state/ ohne Shownotes in der Inbox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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//. inbox/ für das Web liefert sie weiter. Co-Authored-By: Claude Opus 5.5 --- podcasts/tests.py | 2 ++ podcasts/views.py | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/podcasts/tests.py b/podcasts/tests.py index 65e03ce..5e42d6c 100644 --- a/podcasts/tests.py +++ b/podcasts/tests.py @@ -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'}) diff --git a/podcasts/views.py b/podcasts/views.py index 566c624..3892dc6 100644 --- a/podcasts/views.py +++ b/podcasts/views.py @@ -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 = {