Skip to content

Commit

Permalink
- Enables ANY profile to be a tribe (#7080)
Browse files Browse the repository at this point in the history
- makes tribes page load in 0.3s instead of 2s
  • Loading branch information
owocki authored Jul 9, 2020
1 parent 7e5beb4 commit a003655
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
18 changes: 18 additions & 0 deletions app/dashboard/migrations/0126_profile_is_tribe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.4 on 2020-07-08 22:42

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0125_auto_20200630_1304'),
]

operations = [
migrations.AddField(
model_name='profile',
name='is_tribe',
field=models.BooleanField(default=False, help_text='Is this profile a Tribe (only applies to orgs)?'),
),
]
18 changes: 13 additions & 5 deletions app/dashboard/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2753,6 +2753,10 @@ class Profile(SuperModel):
help_text='Is this profile an org?',
db_index=True,
)
is_tribe = models.BooleanField(
default=False,
help_text='Is this profile a Tribe (only applies to orgs)?',
)

average_rating = models.DecimalField(default=0, decimal_places=2, max_digits=50, help_text='avg feedback from those who theyve done work with')
follower_count = models.IntegerField(default=0, db_index=True, help_text='how many users follow them')
Expand Down Expand Up @@ -4010,11 +4014,7 @@ def get_who_works_with(self, work_type='collected', network='mainnet', bounties=
profiles = [org_name(url) for url in github_urls]
profiles = [ele for ele in profiles if ele]
else:
profiles = []
for bounty in bounties:
for bf in bounty.fulfillments.filter(accepted=True):
if bf.fulfiller_github_username:
profiles.append(bf.fulfiller_github_username)
profiles = self.as_dict.get('orgs_bounties_works_with', [])

profiles_dict = {profile: 0 for profile in profiles}
for profile in profiles:
Expand Down Expand Up @@ -4140,11 +4140,19 @@ def to_dict(self):
total_fulfilled = fulfilled_bounties.count() + self.tips.count()
desc = self.get_desc(funded_bounties, fulfilled_bounties)
no_times_been_removed = self.no_times_been_removed_by_funder() + self.no_times_been_removed_by_staff() + self.no_times_slashed_by_staff()
org_works_with = []
if self.is_org:
org_bounties = self.get_orgs_bounties(network='mainnet')
for bounty in org_bounties:
for bf in bounty.fulfillments.filter(accepted=True):
if bf.fulfiller_github_username:
org_works_with.append(bf.fulfiller_github_username)
params = {
'title': f"@{self.handle}",
'active': 'profile_details',
'newsletter_headline': ('Be the first to know about new funded issues.'),
'card_title': f'@{self.handle} | Gitcoin',
'org_works_with': org_works_with,
'card_desc': desc,
'avatar_url': self.avatar_url_with_gitcoin_logo,
'count_bounties_completed': total_fulfilled,
Expand Down
7 changes: 4 additions & 3 deletions app/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2839,7 +2839,7 @@ def profile(request, handle, tab=None):
else:
context['is_on_tribe'] = False

if profile.is_org and profile.handle.lower() in ['gitcoinco']:
if profile.is_org and profile.is_tribe:

active_tab = 0
if tab == "townsquare":
Expand All @@ -2858,10 +2858,10 @@ def profile(request, handle, tab=None):
try:
context['tags'] = get_tags(request)
network = get_default_network()
orgs_bounties = profile.get_orgs_bounties(network=network)
orgs_bounties = profile.get_orgs_bounties(network)
context['count_bounties_on_repo'] = orgs_bounties.count()
context['sum_eth_on_repos'] = profile.get_eth_sum(bounties=orgs_bounties)
context['works_with_org'] = profile.get_who_works_with(work_type='org', bounties=orgs_bounties)
context['works_with_org'] = profile.as_dict.get('works_with_org', [])
context['currentProfile'] = TribesSerializer(profile, context={'request': request}).data
what = f'tribe:{profile.handle}'
try:
Expand All @@ -2879,6 +2879,7 @@ def profile(request, handle, tab=None):

return TemplateResponse(request, 'profiles/tribes-vue.html', context, status=status)
except Exception as e:
raise e # raise so that sentry konws about it and we fix it
logger.info(str(e))


Expand Down
2 changes: 2 additions & 0 deletions app/grants/templates/grants/detail/tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ <h4>Grant Sybil Profile</h4>
- BrightID Trust Score (coming soon)
- Idena Network Trust Score (coming soon)
- KYC (maybe coming soon)
- Inbound WebTraffic Profiles
- Time Series Data

a grant's RiskScore ™️ is equal to its (SybilScore ™️)^2 * sqrt(its matching funds for this round).
</pre>
Expand Down

0 comments on commit a003655

Please sign in to comment.