Skip to content

Commit

Permalink
only use a profiles most recent location to mark a location, for lead…
Browse files Browse the repository at this point in the history
…erboards (#6772)

* only use a profiles most recent location to mark a location, for leaderboards

* fixes for leaderboard / locations

Co-authored-by: Aditya Anand M C <[email protected]>
Co-authored-by: Dan Lipert <[email protected]>
  • Loading branch information
3 people authored Jun 22, 2020
1 parent 20a6574 commit 31f9afa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4210,7 +4210,7 @@ def reassemble_profile_dict(self):
def locations(self):
from app.utils import get_location_from_ip
locations = []
for login in self.actions.filter(action='Login'):
for login in self.actions.filter(action='Login').order_by('-created_on'):
if login.location_data:
locations.append(login.location_data)
else:
Expand Down
3 changes: 2 additions & 1 deletion app/marketing/management/commands/assemble_leaderboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def profile_to_location_helper(handle):
profiles = Profile.objects.filter(handle=handle.lower())
if handle and profiles.exists():
profile = profiles.first()
return profile.locations
if len(profile.locations):
return [profile.locations[0]]
return []


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def test_default_ranks(self):
def test_bounty_index_terms(self):
"""Test bounty index terms list."""
index_terms = bounty_index_terms(self.bounty)
assert len(index_terms) == 15
assert len(index_terms) == 12
assert 'USDT' in index_terms
assert {self.bounty_payer_handle, self.bounty_earner_handle, 'gitcoinco'}.issubset(set(index_terms))
'''
Expand Down

0 comments on commit 31f9afa

Please sign in to comment.