From a003655d95659b8dc849fd782b9f07944e9a8157 Mon Sep 17 00:00:00 2001 From: Kevin Owocki Date: Wed, 8 Jul 2020 23:23:00 -0600 Subject: [PATCH] - Enables ANY profile to be a tribe (#7080) - makes tribes page load in 0.3s instead of 2s --- .../migrations/0126_profile_is_tribe.py | 18 ++++++++++++++++++ app/dashboard/models.py | 18 +++++++++++++----- app/dashboard/views.py | 7 ++++--- app/grants/templates/grants/detail/tabs.html | 2 ++ 4 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 app/dashboard/migrations/0126_profile_is_tribe.py diff --git a/app/dashboard/migrations/0126_profile_is_tribe.py b/app/dashboard/migrations/0126_profile_is_tribe.py new file mode 100644 index 00000000000..a45ec7b40c2 --- /dev/null +++ b/app/dashboard/migrations/0126_profile_is_tribe.py @@ -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)?'), + ), + ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 6d819beab5b..70a9322c579 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -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') @@ -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: @@ -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, diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 4a855d1acc1..ad8642caee4 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -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": @@ -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: @@ -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)) diff --git a/app/grants/templates/grants/detail/tabs.html b/app/grants/templates/grants/detail/tabs.html index d2315f81640..ff514c99ce1 100644 --- a/app/grants/templates/grants/detail/tabs.html +++ b/app/grants/templates/grants/detail/tabs.html @@ -118,6 +118,8 @@

Grant Sybil Profile

- 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).