Commit b615983c3d4302cb6f7711ad59b7ec825dee130f
1 parent
3dfea19e
Exists in
master
and in
39 other branches
Changing filters to use haystack
Showing
1 changed file
with
17 additions
and
11 deletions
Show diff stats
src/badger/utils.py
| @@ -2,15 +2,28 @@ | @@ -2,15 +2,28 @@ | ||
| 2 | 2 | ||
| 3 | from django.db.models import Count | 3 | from django.db.models import Count |
| 4 | 4 | ||
| 5 | +from haystack.query import SearchQuerySet | ||
| 6 | + | ||
| 5 | from proxy.models import Revision, Ticket, Wiki | 7 | from proxy.models import Revision, Ticket, Wiki |
| 6 | from super_archives.models import Message | 8 | from super_archives.models import Message |
| 7 | 9 | ||
| 8 | 10 | ||
| 9 | def get_counters_to_badge(user): | 11 | def get_counters_to_badge(user): |
| 10 | - count_revisions = Revision.objects.filter(author=user.username).count() | ||
| 11 | - count_tickets = Ticket.objects.filter(author=user.username).count() | ||
| 12 | - count_wikis = Wiki.objects.filter(author=user.username).count() | ||
| 13 | - | 12 | + # count_revisions = Revision.objects.filter(author=user.username).count() |
| 13 | + # count_tickets = Ticket.objects.filter(author=user.username).count() | ||
| 14 | + # count_wikis = Wiki.objects.filter(author=user.username).count() | ||
| 15 | + count_revisions = SearchQuerySet().filter( | ||
| 16 | + type='changeset', | ||
| 17 | + author=user.username | ||
| 18 | + ).count() | ||
| 19 | + count_tickets = SearchQuerySet().filter( | ||
| 20 | + type='ticket', | ||
| 21 | + author=user.username | ||
| 22 | + ).count() | ||
| 23 | + count_wikis = SearchQuerySet().filter( | ||
| 24 | + type='wiki', | ||
| 25 | + author=user.username | ||
| 26 | + ).count() | ||
| 14 | return dict( | 27 | return dict( |
| 15 | messages=user.emails.aggregate(Count('message'))['message__count'], | 28 | messages=user.emails.aggregate(Count('message'))['message__count'], |
| 16 | revisions=count_revisions, | 29 | revisions=count_revisions, |
| @@ -18,10 +31,3 @@ def get_counters_to_badge(user): | @@ -18,10 +31,3 @@ def get_counters_to_badge(user): | ||
| 18 | wikis=count_wikis, | 31 | wikis=count_wikis, |
| 19 | contributions=count_revisions + count_tickets + count_wikis, | 32 | contributions=count_revisions + count_tickets + count_wikis, |
| 20 | ) | 33 | ) |
| 21 | - | ||
| 22 | -# using haystack | ||
| 23 | -# sqs = SearchQuerySet() | ||
| 24 | -# sqs.filter(type='changeset', author=user.get_full_name()).count() | ||
| 25 | -# sqs.filter(type='wiki', author=user.get_full_name()).count() | ||
| 26 | -# sqs.filter(type='ticket', author=user.get_full_name()).count() | ||
| 27 | -# Should it use the author_and_username attr too? |