From baf8cb3c7f3820db210160e55dc3b5fdaab5feda Mon Sep 17 00:00:00 2001 From: Graham Dixon Date: Tue, 30 Nov 2021 05:02:21 +0000 Subject: [PATCH] refactor: pksInList checks --- app/retail/views.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/retail/views.py b/app/retail/views.py index 8fea4f136f0..491f59424ad 100644 --- a/app/retail/views.py +++ b/app/retail/views.py @@ -801,16 +801,14 @@ def get_specific_activities(what, trending_only, user, after_pk, request=None, p activity_pks = ActivityIndex.objects.all() # Are the pks already in a list? - pksInList = isinstance(activity_pks, list) - - # Order the activity index data - activity_pks = activity_pks.order_by('-id') if not pksInList else activity_pks - - if page: + if not isinstance(activity_pks, list): + # Order the activity index data + activity_pks = activity_pks.order_by('-id') # Pagination is done here - activity_pks = activity_pks[start_index:end_index].values_list('activity_id', flat=True) if not pksInList else activity_pks - else: - activity_pks = activity_pks.values_list('activity_id', flat=True) if not pksInList else activity_pks + if page: + activity_pks = activity_pks[start_index:end_index].values_list('activity_id', flat=True) + else: + activity_pks = activity_pks.values_list('activity_id', flat=True) # Cross-ref the activity_pks->activity_id with the Activity objects activities = Activity.objects.filter(pk__in=list(activity_pks),hidden=False).order_by('-created_on')