Skip to content

Commit

Permalink
stable -> master (#5623)
Browse files Browse the repository at this point in the history
* fix chat icon and tribe link

* vivek request

* responsive for tribes cards

* Update emails.py

* use actual emojis instead of bytecode

* adds weekly leaderboard ranks to the activity feed

* small fix

* reenable trad leaderboards

* one last fix
  • Loading branch information
thelostone-mc authored Dec 11, 2019
1 parent 81406e6 commit 0641f7f
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 129 deletions.
20 changes: 19 additions & 1 deletion app/assets/v2/css/profile.css
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,28 @@ nav.navbar.navbar-dark{

.tribe-members {
display: grid;
grid-template-columns: repeat(5, 1fr);
grid-template-columns: repeat(1, 1fr);
grid-gap: 3rem 1rem;
}

@media (min-width: 768px) {
.tribe-members {
grid-template-columns: repeat(2, 1fr);
}
}

@media (min-width: 992px) {
.tribe-members {
grid-template-columns: repeat(4, 1fr);
}
}

@media (min-width: 1200px) {
.tribe-members {
grid-template-columns: repeat(5, 1fr);
}
}

.badge-tribe {
position: absolute;
top: 33px;
Expand Down
12 changes: 12 additions & 0 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4103,6 +4103,18 @@ def get_absolute_url(self):
"""
return settings.BASE_URL + f'hackathon/{self.slug}'

@property
def onboard_url(self):
return self.get_onboard_url()

def get_onboard_url(self):
"""Get the absolute URL for the HackathonEvent.
Returns:
str: The absolute URL for the HackathonEvent.
"""
return settings.BASE_URL + f'hackathon/onboard/{self.slug}/'

@property
def get_current_bounties(self):
Expand Down
3 changes: 3 additions & 0 deletions app/dashboard/templates/profiles/header_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

<h1 class="profile-header__handle">
{{ profile.name }}
{% if is_staff and not profile.is_org %}
<button class="btn btn-outline-gc-blue btn-sm flex-grow-1" data-openchat="{{profile}}"> <i class="fas fa-comment-dots"></i></button>
{% endif %}
{% if verification %}
<button class="btn btn-sm animate-verify" data-container="body" data-toggle="popover" data-html="true" data-placement="bottom" data-trigger="hover click" data-content='
<p class="h6 my-2 text-left">Gitcoin Verified <img width="18" src="{% static "v2/images/badge-verify.svg" %}"></p>
Expand Down
4 changes: 2 additions & 2 deletions app/dashboard/templates/profiles/tab_tribe.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h5 class="font-weight-bold">About {{profile.name}}</h5>
{% if is_my_org %}
<div class="">
<button class="btn btn-gc-blue btn-sm" id="edit-btn">Edit</button>
<button class="btn btn-gc-blue btn-sm d-none" id="save-description-btn" data-savetribe="{{profile.handle}}">save</button>
<button class="btn btn-gc-blue btn-sm d-none" id="save-description-btn" data-savetribe="{{profile.handle}}">Save</button>
</div>
{% endif %}
</div>
Expand Down Expand Up @@ -62,7 +62,7 @@ <h5 class="font-weight-bold">
Tribe members <span class="badge badge-pill badge--bluelight">{{profile.tribe_members.count}}</span>
</h5>
<p class="text-muted">
Members of the {{profile.name}} Tribe. <a class="underline" href="{% url 'tribes' %}">What is a Tribe?</a>
Members of the {{profile.name}} Tribe. <a class="underline" data-container="body" data-toggle="popover" data-html="true" data-placement="bottom" data-trigger="hover click" data-content='<p class="title">Gitcoin Tribes</p><p>Takes hackathon sponsorship to the next level, with features for maintaining relationships / creating relationships in ways never before possible in a virtual context.</p><p>Build your Gitcoin Tribe through monthly Gitcoin hackathons and a variety of tools to incentivize open source developers and build increasingly interesting projects together.</p>' href="#">What is a Tribe?</a>
</p>
<div class="tribe-members pt-4 mt-4">
{% for follower in profile.tribe_members %}
Expand Down
186 changes: 103 additions & 83 deletions app/marketing/management/commands/assemble_leaderboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,91 +382,111 @@ def should_suppress_leaderboard(handle):
return False


def do_leaderboard_feed():
from dashboard.models import Activity
max_rank = 25
for _type in [PAYERS, EARNERS, ORGS]:
key = f'{WEEKLY}_{_type}'
lrs = LeaderboardRank.objects.active().filter(leaderboard=key, rank__lte=max_rank, product='all')
print(key, lrs.count())
for lr in lrs:
metadata = {
'title': f"was ranked #{lr.rank} on the Gitcoin Weekly {_type.title()} Leaderboard",
'link': f'/leaderboard/{_type}'
}
if lr.profile:
Activity.objects.create(profile=lr.profile, activity_type='leaderboard_rank', metadata=metadata)


def do_leaderboard():
global ranks
global counts

products = ['kudos', 'grants', 'bounties', 'tips', 'all']
for product in products:

ranks = default_ranks()
counts = default_ranks()
index_terms = []

if product in ['all', 'grants']:
# get grants
grants = Contribution.objects.filter(subscription__network='mainnet')
# iterate
for gc in grants:
index_terms = grant_index_terms(gc)
sum_grants(gc, index_terms)

if product in ['all', 'bounties']:
# get bounties
bounties = Bounty.objects.current().filter(network='mainnet')

# iterate
for b in bounties:
if not b._val_usd_db:
continue

index_terms = bounty_index_terms(b)
sum_bounties(b, index_terms)

if product in ['all', 'tips']:
# get tips
tips = Tip.objects.send_success().filter(network='mainnet')

# iterate
for t in tips:
if not t.value_in_usdt_now:
continue
index_terms = tip_index_terms(t)
sum_tips(t, index_terms)

if product in ['all', 'kudos']:
# kudos'
for kt in KudosTransfer.objects.send_success().filter(network='mainnet'):
sum_kudos(kt)

# set old LR as inactive
with transaction.atomic():
lrs = LeaderboardRank.objects.active().filter(product=product)
lrs.update(active=False)

# save new LR in DB
for key, rankings in ranks.items():
rank = 1
for index_term, amount in sorted(rankings.items(), key=lambda x: x[1], reverse=True):
count = counts[key][index_term]
lbr_kwargs = {
'count': count,
'active': True,
'amount': amount,
'rank': rank,
'leaderboard': key,
'github_username': index_term,
'product': product,
}

try:
profile = Profile.objects.get(handle__iexact=index_term)
lbr_kwargs['profile'] = profile
lbr_kwargs['tech_keywords'] = profile.keywords
except Profile.MultipleObjectsReturned:
profile = Profile.objects.filter(handle__iexact=index_term).latest('id')
lbr_kwargs['profile'] = profile
lbr_kwargs['tech_keywords'] = profile.keywords
print(f'Multiple profiles found for username: {index_term}')
except Profile.DoesNotExist:
print(f'No profiles found for username: {index_term}')

# TODO: Bucket LeaderboardRank objects and .bulk_create
LeaderboardRank.objects.create(**lbr_kwargs)
rank += 1
print(key, index_term, amount, count, rank, product)


class Command(BaseCommand):

help = 'creates leaderboard objects'

def handle(self, *args, **options):

global ranks
global counts

products = ['kudos', 'grants', 'bounties', 'tips', 'all']
for product in products:

ranks = default_ranks()
counts = default_ranks()
index_terms = []

if product in ['all', 'grants']:
# get grants
grants = Contribution.objects.filter(subscription__network='mainnet')
# iterate
for gc in grants:
index_terms = grant_index_terms(gc)
sum_grants(gc, index_terms)

if product in ['all', 'bounties']:
# get bounties
bounties = Bounty.objects.current().filter(network='mainnet')

# iterate
for b in bounties:
if not b._val_usd_db:
continue

index_terms = bounty_index_terms(b)
sum_bounties(b, index_terms)

if product in ['all', 'tips']:
# get tips
tips = Tip.objects.send_success().filter(network='mainnet')

# iterate
for t in tips:
if not t.value_in_usdt_now:
continue
index_terms = tip_index_terms(t)
sum_tips(t, index_terms)

if product in ['all', 'kudos']:
# kudos'
for kt in KudosTransfer.objects.send_success().filter(network='mainnet'):
sum_kudos(kt)

# set old LR as inactive
with transaction.atomic():
lrs = LeaderboardRank.objects.active().filter(product=product)
lrs.update(active=False)

# save new LR in DB
for key, rankings in ranks.items():
rank = 1
for index_term, amount in sorted(rankings.items(), key=lambda x: x[1], reverse=True):
count = counts[key][index_term]
lbr_kwargs = {
'count': count,
'active': True,
'amount': amount,
'rank': rank,
'leaderboard': key,
'github_username': index_term,
'product': product,
}

try:
profile = Profile.objects.get(handle__iexact=index_term)
lbr_kwargs['profile'] = profile
lbr_kwargs['tech_keywords'] = profile.keywords
except Profile.MultipleObjectsReturned:
profile = Profile.objects.filter(handle__iexact=index_term).latest('id')
lbr_kwargs['profile'] = profile
lbr_kwargs['tech_keywords'] = profile.keywords
print(f'Multiple profiles found for username: {index_term}')
except Profile.DoesNotExist:
print(f'No profiles found for username: {index_term}')

# TODO: Bucket LeaderboardRank objects and .bulk_create
LeaderboardRank.objects.create(**lbr_kwargs)
rank += 1
print(key, index_term, amount, count, rank, product)
do_leaderboard()
do_leaderboard_feed()
2 changes: 1 addition & 1 deletion app/quests/templates/quests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ <h2 style="margin-top: -50px; font-size: 20px;">
{%else%}
🔒Locked; To unlock
{% if quest.unlocked_by_hackathon %}
register for <a href="{{quest.unlocked_by_hackathon.url}}">{{quest.unlocked_by_hackathon.name}}</a>.
register for <a href="{{quest.unlocked_by_hackathon.onboard_url}}">{{quest.unlocked_by_hackathon.name}}</a>.
{%else%}
beat <a href="{{quest.unlocked_by_quest.url}}">{{quest.unlocked_by_quest.title}}</a>.
{%endif%}
Expand Down
Loading

0 comments on commit 0641f7f

Please sign in to comment.