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

Commit

Permalink
[bug 966426] Add has_email filter to analyzer search
Browse files Browse the repository at this point in the history
  • Loading branch information
willkg committed Feb 13, 2014
1 parent fcbd872 commit 030fe96
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions fjord/analytics/analyzer_views.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ def analytics_search(request):
# Note: If we add additional querystring fields, we need to add # Note: If we add additional querystring fields, we need to add
# them to generate_dashboard_url. # them to generate_dashboard_url.
search_happy = request.GET.get('happy', None) search_happy = request.GET.get('happy', None)
search_has_email = request.GET.get('has_email', None)
search_platform = request.GET.get('platform', None) search_platform = request.GET.get('platform', None)
search_locale = request.GET.get('locale', None) search_locale = request.GET.get('locale', None)
search_product = request.GET.get('product', None) search_product = request.GET.get('product', None)
Expand All @@ -294,6 +295,13 @@ def analytics_search(request):
f &= F(happy=search_happy) f &= F(happy=search_happy)
current_search['happy'] = int(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): def unknown_to_empty(text):
"""Convert "Unknown" to "" to support old links""" """Convert "Unknown" to "" to support old links"""
return u'' if text.lower() == u'unknown' else text return u'' if text.lower() == u'unknown' else text
Expand Down Expand Up @@ -371,7 +379,7 @@ def unknown_to_empty(text):


# Navigation facet data # Navigation facet data
facets = search.facet( facets = search.facet(
'happy', 'platform', 'locale', 'product', 'version', 'happy', 'platform', 'locale', 'product', 'version', 'has_email',
filtered=bool(search._process_filters(f.filters))) filtered=bool(search._process_filters(f.filters)))


# This loop does two things. First it maps 'T' -> True and 'F' -> # This loop does two things. First it maps 'T' -> True and 'F' ->
Expand All @@ -380,10 +388,11 @@ def unknown_to_empty(text):
# form. # form.
counts = { counts = {
'happy': {}, 'happy': {},
'has_email': {},
'platform': {}, 'platform': {},
'locale': {}, 'locale': {},
'product': {}, 'product': {},
'version': {} 'version': {},
} }
for param, terms in facets.facet_counts().items(): for param, terms in facets.facet_counts().items():
for term in terms: for term in terms:
Expand All @@ -406,6 +415,13 @@ def empty_to_unknown(text):
display_map={True: 'Happy', False: 'Sad'}, display_map={True: 'Happy', False: 'Sad'},
value_map={True: 1, False: 0}, value_map={True: 1, False: 0},
checked=search_happy), 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_to_options(
counts['product'].items(), counts['product'].items(),
name='product', name='product',
Expand Down

0 comments on commit 030fe96

Please sign in to comment.