Permalink
Browse files

[bug 966426] Add has_email filter to analyzer search

  • Loading branch information...
1 parent fcbd872 commit 030fe96b14cfa8b46d7acc64a6e2043678b1ea4d @willkg willkg committed Feb 13, 2014
Showing with 18 additions and 2 deletions.
  1. +18 −2 fjord/analytics/analyzer_views.py
View
20 fjord/analytics/analyzer_views.py
@@ -271,6 +271,7 @@ def analytics_search(request):
# Note: If we add additional querystring fields, we need to add
# them to generate_dashboard_url.
search_happy = request.GET.get('happy', None)
+ search_has_email = request.GET.get('has_email', None)
search_platform = request.GET.get('platform', None)
search_locale = request.GET.get('locale', None)
search_product = request.GET.get('product', None)
@@ -294,6 +295,13 @@ def analytics_search(request):
f &= F(happy=search_happy)
current_search['happy'] = int(search_happy)
+ # If search has_email is '0' or '1', set it to False or True,
+ # respectively.
+ search_has_email = {'0': False, '1': True}.get(search_has_email, None)
+ if search_has_email in [False, True]:
+ f &= F(has_email=search_has_email)
+ current_search['has_email'] = int(search_has_email)
+
def unknown_to_empty(text):
"""Convert "Unknown" to "" to support old links"""
return u'' if text.lower() == u'unknown' else text
@@ -371,7 +379,7 @@ def unknown_to_empty(text):
# Navigation facet data
facets = search.facet(
- 'happy', 'platform', 'locale', 'product', 'version',
+ 'happy', 'platform', 'locale', 'product', 'version', 'has_email',
filtered=bool(search._process_filters(f.filters)))
# This loop does two things. First it maps 'T' -> True and 'F' ->
@@ -380,10 +388,11 @@ def unknown_to_empty(text):
# form.
counts = {
'happy': {},
+ 'has_email': {},
'platform': {},
'locale': {},
'product': {},
- 'version': {}
+ 'version': {},
}
for param, terms in facets.facet_counts().items():
for term in terms:
@@ -407,6 +416,13 @@ def empty_to_unknown(text):
value_map={True: 1, False: 0},
checked=search_happy),
counts_to_options(
+ counts['has_email'].items(),
+ name='has_email',
+ display='Has email',
+ display_map={True: 'Yes', False: 'No'},
+ value_map={True: 1, False: 0},
+ checked=search_has_email),
+ counts_to_options(
counts['product'].items(),
name='product',
display='Product',

0 comments on commit 030fe96

Please sign in to comment.