Skip to content

Commit

Permalink
support for any cadence on the leaderboard
Browse files Browse the repository at this point in the history
  • Loading branch information
owocki committed Jul 20, 2019
1 parent a799678 commit e8b7063
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 49 deletions.
11 changes: 9 additions & 2 deletions app/assets/v2/js/pages/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@ $(document).ready(function() {
document.location.href = `/leaderboard/${val}`;
});


$('#cadence').change(function() {

document.location.href = document.location.pathname + '?cadence=' + $('#cadence').val() + '&keyword=' + $('#tech-keyword').val();
});


$('#tech-keyword').change(function() {
const keyword = $(this).val();

if (keyword === 'all') {
var new_location = window.location.href.split('?')[0];
document.location.href = document.location.pathname + '?cadence=' + $('#cadence').val() + '&keyword=';

window.location.href = new_location;
} else {
Expand All @@ -52,7 +59,7 @@ $(document).ready(function() {
base_url = window.location.href.split('?')[0];
}

window.location.href = base_url + `?keyword=${keyword}`;
document.location.href = document.location.pathname + '?cadence=' + $('#cadence').val() + '&keyword=' + $('#tech-keyword').val();
}
});
});
51 changes: 21 additions & 30 deletions app/marketing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,38 +670,26 @@ def leaderboard(request, key=''):
TemplateResponse: The leaderboard template response.
"""
if not key:
key = 'quarterly_earners'
cadences = ['all', 'weekly', 'monthly', 'quarterly', 'yearly']

keyword_search = request.GET.get('keyword')
keyword_search = request.GET.get('keyword', '')
limit = request.GET.get('limit', 25)

cadence = request.GET.get('cadence', 'quarterly')
titles = {
'quarterly_payers': _('Top Payers'),
'quarterly_earners': _('Top Earners'),
'quarterly_orgs': _('Top Orgs'),
'quarterly_tokens': _('Top Tokens'),
'quarterly_keywords': _('Top Keywords'),
'quarterly_kudos': _('Top Kudos'),
'quarterly_cities': _('Top Cities'),
'quarterly_countries': _('Top Countries'),
'quarterly_continents': _('Top Continents'),
# 'weekly_fulfilled': 'Weekly Leaderboard: Fulfilled Funded Issues',
# 'weekly_all': 'Weekly Leaderboard: All Funded Issues',
# 'monthly_fulfilled': 'Monthly Leaderboard',
# 'monthly_all': 'Monthly Leaderboard: All Funded Issues',
# 'yearly_fulfilled': 'Yearly Leaderboard: Fulfilled Funded Issues',
# 'yearly_all': 'Yearly Leaderboard: All Funded Issues',
# 'all_fulfilled': 'All-Time Leaderboard: Fulfilled Funded Issues',
# 'all_all': 'All-Time Leaderboard: All Funded Issues',
# TODO - also include options for weekly, yearly, and all cadences of earning
f'{cadence}_payers': _('Top Funders'),
f'{cadence}_earners': _('Top Coders'),
f'{cadence}_orgs': _('Top Orgs'),
f'{cadence}_tokens': _('Top Tokens'),
f'{cadence}_keywords': _('Top Keywords'),
f'{cadence}_kudos': _('Top Kudos'),
f'{cadence}_cities': _('Top Cities'),
f'{cadence}_countries': _('Top Countries'),
f'{cadence}_continents': _('Top Continents'),
}

if settings.ENV != 'prod':
# TODO (mbeacom): Re-enable this on live following a fix for leaderboards by location.
titles['quarterly_cities'] = _('Top Cities')
titles['quarterly_countries'] = _('Top Countries')
titles['quarterly_continents'] = _('Top Continents')
if not key:
key = f'{cadence}_earners'


if key not in titles.keys():
raise Http404
Expand Down Expand Up @@ -737,16 +725,19 @@ def leaderboard(request, key=''):
'items': items[0:limit],
'nav': 'home',
'titles': titles,
'cadence': cadence,
'selected': title,
'is_linked_to_profile': is_linked_to_profile,
'title': f'Leaderboard: {title}',
'card_title': f'Leaderboard: {title}',
'title': f'{keyword_search} Leaderboard: {title}',
'card_title': f'{keyword_search} Leaderboard: {title}',
'card_desc': f'See the most valued members in the Gitcoin community recently . {top_earners}',
'action_past_tense': 'Transacted' if 'submitted' in key else 'bountied',
'amount_max': amount_max,
'podium_items': items[:5] if items else [],
'technologies': technologies,
'active': 'leaderboard'
'active': 'leaderboard',
'keyword_search': keyword_search,
'cadences': cadences,
}

return TemplateResponse(request, 'leaderboard.html', context)
Expand Down
52 changes: 35 additions & 17 deletions app/retail/templates/leaderboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,49 @@ <h6 class="pt-3 pb-2 text-center">
<!-- RESULTS TITLE & FILTER -->

<div class="col-12 my-auto col-lg-6 text-center text-md-left">
<h3 class="font-subheader font-weight-semibold mb-lg-0">Quarterly {{ title }}</h3>
<h1 class="font-header font-weight-semibold mb-lg-0">{{cadence|title}} {{ title }} </h1>
</div>
<div class="col-12 col-sm-6 col-lg-3 mx-auto my-2 my-md-0 text-center text-sm-right text-lg-left">
{% if technologies|length > 0 %}
<p class="key-title font-body mb-0 font-weight-semibold mr-2">Key :</p>
<div class="form-group text-center text-md-right d-inline">
<select id="tech-keyword" class="form-control tech-options key">
<option value="all">All</option>
</select>
</div>
{% endif %}
</div>

<!-- END RESULTS TITLE & FILTER -->

<div class="col-12 col-sm-6 col-lg-3 select mx-auto my-2 my-md-0 text-center text-lg-left">
<div class="form-group text-center text-md-right d-inline">
<p class="key-title font-body mb-0 font-weight-semibold mr-2">Type :</p>
<select id="key" class="form-control key font-body">
{% for this_title in titles.items %}
<option value="{{this_title.0}}"
{% if selected == this_title.1 %}selected=selected{% endif %} >{{this_title.1}}
</option>
{% endfor %}
</select>

<div class=" mt-2">
<p class="key-title font-body mb-0 font-weight-semibold mr-2">Type : &nbsp; &nbsp; &nbsp; </p>
<select id="key" class="form-control key font-body">
{% for this_title in titles.items %}
<option value="{{this_title.0}}"
{% if selected == this_title.1 %}selected=selected{% endif %} >{{this_title.1}}
</option>
{% endfor %}
</select>
</div>

<div class=" mt-2">
<p class="key-title font-body mb-0 font-weight-semibold mr-2">Cadence :</p>
<select id="cadence" class="form-control key font-body">
{% for ele in cadences %}
<option value="{{ele}}"
{% if cadence == ele %}selected=selected{% endif %} >{{ele|title}}
</option>
{% endfor %}
</select>
</div>

<div class=" mt-2">
{% if technologies|length > 0 %}
<p class="key-title font-body mb-0 font-weight-semibold mr-2">Key : &nbsp; &nbsp; &nbsp; &nbsp;</p>
<div class="form-group text-center text-md-right d-inline">
<select id="tech-keyword" class="form-control tech-options key">
<option value="all">All</option>
</select>
</div>
{% endif %}
</div>

</div>
</div>
</div>
Expand Down

0 comments on commit e8b7063

Please sign in to comment.