Skip to content

Commit

Permalink
leaderboard goodness, re-enables location leaderboards with caching -…
Browse files Browse the repository at this point in the history
…- time profile:

real	13m38.270s
user	5m54.660s
sys	1m0.440s
  • Loading branch information
owocki committed Nov 2, 2018
1 parent 72d2860 commit 2314ead
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
20 changes: 17 additions & 3 deletions app/marketing/management/commands/assemble_leaderboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from cacheops import CacheMiss, cache
from django.conf import settings
from django.core.management.base import BaseCommand
from django.utils import timezone
Expand Down Expand Up @@ -76,9 +77,22 @@ def default_ranks():


def profile_to_location(handle):
# TODO (mbeacom): Debug, fix, and re-enable leaderboards by location on live.
if settings.ENV == 'prod':
return []
timeout = 60 * 20
key_salt = '1'
key = f'profile_to_location{handle}_{key_salt}'
try:
results = cache.get(key)
except CacheMiss:
results = None

if not results:
results = profile_to_location_helper(handle)
cache.set(key, results, timeout)

return results


def profile_to_location_helper(handle):

profiles = Profile.objects.filter(handle__iexact=handle)
if handle and profiles.exists():
Expand Down
6 changes: 3 additions & 3 deletions app/marketing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,9 @@ def leaderboard(request, key=''):
'quarterly_tokens': _('Top Tokens'),
'quarterly_keywords': _('Top Keywords'),
'quarterly_kudos': _('Top Kudos'),
# 'quarterly_cities': _('Top Cities'),
# 'quarterly_countries': _('Top Countries'),
# 'quarterly_continents': _('Top Continents'),
'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',
Expand Down
2 changes: 1 addition & 1 deletion app/retail/templates/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ <h5>{% trans "and by Type" %}</h5>
<div class="row py-2 animatedParent">
<div class="col-12 col-lg-10 offset-md-0 offset-lg-1 d-flex flex-sm-row flex-column justify-content-center align-items-center">
<p style='text-align: center;'>
Since it's <a href="https://media.consensys.net/gitcoin-joins-consensys-announces-pilot-projects-f5a0955de9d6" target="_blank">launch</a> in <span style="margin: 3px 3px; font-weight: bold;">November 2017</span>, Gitcoin has helped <span style="margin: 3px 3px;font-weight: bold;">{{funders|intcomma}}</span> funders reach an audience of <span style="margin: 3px 3px;font-weight: bold;">{{audience|intcomma}}</span> developers. Gitcoin has facilitated <span style="margin: 3px 3px;font-weight: bold;">{{transactions|intcomma}}</span> complete transactions to <span style="margin: 3px 3px;font-weight: bold;">{{recipients|intcomma}}</span> unique coders.
Since its <a href="https://media.consensys.net/gitcoin-joins-consensys-announces-pilot-projects-f5a0955de9d6" target="_blank">launch</a> in <span style="margin: 3px 3px; font-weight: bold;">November 2017</span>, Gitcoin has helped <span style="margin: 3px 3px;font-weight: bold;">{{funders|intcomma}}</span> funders reach an audience of <span style="margin: 3px 3px;font-weight: bold;">{{audience|intcomma}}</span> developers. Gitcoin has facilitated <span style="margin: 3px 3px;font-weight: bold;">{{transactions|intcomma}}</span> complete transactions to <span style="margin: 3px 3px;font-weight: bold;">{{recipients|intcomma}}</span> unique coders.
</p>
</div>
</div>
Expand Down

0 comments on commit 2314ead

Please sign in to comment.