Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
BitField doesn't work with subqueries
Browse files Browse the repository at this point in the history
See disqus/django-bitfield#31

(We were also slicing the first QuerySet, so we probably should have been doing it this way from the start anyway)
  • Loading branch information
moggers87 committed May 16, 2014
1 parent 3f28fd4 commit ee00d1d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ def statistics():
@task(ignore_result=True)
@transaction.atomic()
def inbox_new_flag(user_id, inbox_id=None):
emails = Email.objects.order_by("-received_date").filter(inbox__flags=~Inbox.flags.exclude_from_unified, inbox__user__id=user_id)
emails = Email.objects.order_by("-received_date").only('id')
emails = emails.filter(inbox__user__id=user_id, inbox__flags=~Inbox.flags.exclude_from_unified)
if inbox_id is not None:
emails = emails.filter(inbox__id=inbox_id)
emails = emails[:100] # number of emails on page
emails = [email.id for email in emails[:100]] # number of emails on page
emails = Email.objects.filter(id__in=emails, flags=~Email.flags.seen)

# if some emails haven't been seen yet, we have nothing else to do
Expand Down

0 comments on commit ee00d1d

Please sign in to comment.