Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
owocki committed Mar 7, 2020
2 parents ced2025 + 118f68e commit 81e9028
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,8 @@ class Activity(SuperModel):
('created_quest', 'Created Quest'),
('updated_avatar', 'Updated Avatar'),
('mini_clr_payout', 'Mini CLR Payout'),
('leaderboard_rank', 'Leaderboard Rank'),
('consolidated_leaderboard_rank', 'Consolidated Leaderboard Rank'),
]

profile = models.ForeignKey(
Expand Down Expand Up @@ -2267,7 +2269,7 @@ def view_props(self):
if getattr(self, fk):
activity[fk] = getattr(self, fk).to_standard_dict(properties=properties)
activity['secondary_avatar_url'] = self.secondary_avatar_url
activity['staff'] = self.profile.user.is_staff if self.profile and hasattr(self.profile, 'user') else False
activity['staff'] = self.profile.user.is_staff if self.profile and hasattr(self.profile, 'user') and self.profile.user else False

# KO notes 2019/01/30
# this is a bunch of bespoke information that is computed for the views
Expand Down
18 changes: 18 additions & 0 deletions app/marketing/management/commands/assemble_leaderboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,24 @@ def do_leaderboard_feed():
if lr.profile:
Activity.objects.create(profile=lr.profile, activity_type='leaderboard_rank', metadata=metadata)

profile = Profile.objects.filter(handle='gitcoinbot').first()
for _type in [PAYERS, EARNERS, ORGS, CITIES, TOKENS]:
url = f'/leaderboard/{_type}'
what = _type.title() if _type != PAYERS else "Funders"
key = f'{WEEKLY}_{_type}'
lrs = LeaderboardRank.objects.active().filter(leaderboard=key, rank__lte=max_rank, product='all').order_by('rank')[0:10]
copy = f"<a href={url}>Weekly {what} Leaderboard</a>:<BR>"
counter = 0
for lr in lrs:
profile_link = f"<a href=/{lr.profile}>@{lr.profile}</a>" if _type not in [CITIES, TOKENS] else f"<strong>{lr.github_username}</strong>"
copy += f" - {profile_link} was ranked <strong>#{lr.rank}</strong>. <BR>"
metadata = {
'copy': copy,
}
key = f'{WEEKLY}_{_type}'
Activity.objects.create(profile=profile, activity_type='consolidated_leaderboard_rank', metadata=metadata)



def do_leaderboard():
global ranks
Expand Down
3 changes: 3 additions & 0 deletions app/retail/templates/shared/activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@
{% endif %}
:
<b>{{ row.metadata.title }}</b>
{% elif row.activity_type == 'consolidated_leaderboard_rank' %}
{{row.metadata.copy|safe}}

{% elif row.activity_type == 'leaderboard_rank' %}
<a href="{{ row.metadata.link }}">{{ row.metadata.title }}</a>
{% elif row.activity_type == 'new_bounty' %}
Expand Down
4 changes: 2 additions & 2 deletions app/retail/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ def get_specific_activities(what, trending_only, user, after_pk, request=None):
if 'search-' in what:
keyword = what.split('-')[1]
view_count_threshold = 5
base_filter = Q(metadata__icontains=keyword, activity_type__in=['status_update', 'wall_post', 'new_bounty', 'created_quest', 'new_grant', 'created_kudos', 'mini_clr_payout'])
base_filter = Q(metadata__icontains=keyword, activity_type__in=['status_update', 'wall_post', 'new_bounty', 'created_quest', 'new_grant', 'created_kudos', 'mini_clr_payout', 'consolidated_leaderboard_rank'])
keyword_filter = Q(pk=0) #noop
if keyword == 'meme':
keyword_filter = Q(metadata__type='gif') | Q(metadata__type='png') | Q(metadata__type='jpg')
Expand All @@ -1198,7 +1198,7 @@ def get_specific_activities(what, trending_only, user, after_pk, request=None):
if len(relevant_grants):
activities = activities.filter(grant__in=relevant_grants)
if what == 'connect':
activities = activities.filter(activity_type__in=['status_update', 'wall_post', 'new_bounty', 'created_quest', 'mini_clr_payout', 'new_grant', 'created_kudos',])
activities = activities.filter(activity_type__in=['status_update', 'wall_post', 'new_bounty', 'created_quest', 'new_grant', 'created_kudos', 'mini_clr_payout', 'consolidated_leaderboard_rank'])
if what == 'kudos':
activities = activities.filter(activity_type__in=['new_kudos', 'receive_kudos'])

Expand Down

0 comments on commit 81e9028

Please sign in to comment.