userlist queries now only look at first 100 works
parent
41f41aa76e
commit
7b6b1d067f
|
@ -28,11 +28,11 @@ def work_list_users(work_list, how_many):
|
|||
"""return up to how_many users with one of the works on work_list in their wishlist"""
|
||||
#users = User.objects.filter(wishlist__works__in=work_list).distinct().reverse()
|
||||
# for MySQL, avoiding a nested query is more efficient: https://docs.djangoproject.com/en/dev/ref/models/querysets/#in
|
||||
users = User.objects.filter(wishlist__works__in=list(work_list)).distinct().reverse()
|
||||
users = User.objects.filter(wishlist__works__in=list(work_list[:100])).distinct().reverse()
|
||||
return users.all()[0:how_many]
|
||||
|
||||
def campaign_list_users(campaign_list, how_many):
|
||||
users = User.objects.filter(wishlist__works__campaigns__in=list(campaign_list)).distinct().reverse()
|
||||
users = User.objects.filter(wishlist__works__campaigns__in=list(campaign_list[:100])).distinct().reverse()
|
||||
count = users.count()
|
||||
if count <= how_many :
|
||||
user_list = users[0: count]
|
||||
|
|
|
@ -68,7 +68,6 @@ def home(request):
|
|||
# on the preview site there are no active campaigns, so we should show most-wished books instead
|
||||
is_preview = settings.IS_PREVIEW
|
||||
if is_preview:
|
||||
# django related fields and distinct() interact poorly, so we need to do a song and dance to get distinct works
|
||||
worklist = models.Work.objects.order_by('-num_wishes')
|
||||
works = worklist[:6]
|
||||
works2 = worklist[6:12]
|
||||
|
|
Loading…
Reference in New Issue