From e76eead5f2427df4c78df816855b78ad516d0775 Mon Sep 17 00:00:00 2001 From: owocki Date: Wed, 29 Sep 2021 20:42:57 -0600 Subject: [PATCH 1/6] talk --- app/retail/templates/mission.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/retail/templates/mission.html b/app/retail/templates/mission.html index 3f85b6f4fcf..b3532059989 100644 --- a/app/retail/templates/mission.html +++ b/app/retail/templates/mission.html @@ -205,6 +205,12 @@

EthCC 2021 - DoingGud


+

Bankless 2021 - Layer 0 Interview with Kevin Owocki

+ +
+
+ + From 486c87f643ddd3a59336118d5a960e1d2a490789 Mon Sep 17 00:00:00 2001 From: owocki Date: Thu, 30 Sep 2021 11:25:42 -0600 Subject: [PATCH 2/6] removes suggested tribes from town square --- app/townsquare/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/townsquare/views.py b/app/townsquare/views.py index 9be3abde866..7d6bb7d1884 100644 --- a/app/townsquare/views.py +++ b/app/townsquare/views.py @@ -324,6 +324,7 @@ def ignored_suggested_tribe(request, tribeId): def get_suggested_tribes(request): + return [] following_tribes = [] tribe_limit = 5 From aa772b52a515db6ac28488b974069a55349f34aa Mon Sep 17 00:00:00 2001 From: owocki Date: Thu, 30 Sep 2021 13:02:23 -0600 Subject: [PATCH 3/6] fix for https://app.datadoghq.com/apm/traces?query=env%3Aprod%20service%3Adjango%20%40duration%3A%3E%3D4.2s&cols=core_service%2Ccore_resource_name%2Clog_duration%2Clog_http.method%2Clog_http.status_code&historicalData=false&messageDisplay=inline&sort=desc&spanID=9747696918608759014&streamTraces=true&timeHint=1633027431015&trace=1169822777201466218814426228875431949465&traceID=11698227772014662188&start=1633027596684&end=1633028496684&paused=false --- app/dashboard/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 800149bc927..c8cfee6bc4d 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -2268,8 +2268,9 @@ def profile_activity(request, handle): except (ProfileNotFoundException, ProfileHiddenException): raise Http404 + date = timezone.now() - timezone.timedelta(days=365) activities = list(profile.get_various_activities().values_list('created_on', flat=True)) - activities += list(profile.actions.values_list('created_on', flat=True)) + activities += list(profile.actions.filter(created_on__gt=date).values_list('created_on', flat=True)) response = {} prev_date = timezone.now() for i in range(1, 12*30): From 30a64b34c9176ca262b7b49eda5496cc9451935d Mon Sep 17 00:00:00 2001 From: owocki Date: Fri, 1 Oct 2021 15:46:28 -0600 Subject: [PATCH 4/6] fixes slow activity query... somewhat --- app/retail/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/retail/views.py b/app/retail/views.py index 343b1b008b2..b7bfb95dcfc 100644 --- a/app/retail/views.py +++ b/app/retail/views.py @@ -849,7 +849,7 @@ def get_specific_activities(what, trending_only, user, after_pk, request=None): view_count_threshold = 40 activities = activities.filter(view_count__gt=view_count_threshold) - activities = activities.filter().exclude(pin__what=what) + activities = activities return activities From e8efff937e51f94f2d987d5721e16a39a0930ed2 Mon Sep 17 00:00:00 2001 From: owocki Date: Fri, 1 Oct 2021 21:06:41 -0600 Subject: [PATCH 5/6] fixes various performance issues via https://app.datadoghq.com/apm/traces --- .../migrations/0188_auto_20211002_0156.py | 18 +++++++++++++++ app/dashboard/models.py | 5 +++-- app/grants/views.py | 9 ++++---- app/quests/views.py | 22 ++++++++++--------- app/retail/templates/shared/activity.html | 7 ------ app/retail/views.py | 4 +--- 6 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 app/dashboard/migrations/0188_auto_20211002_0156.py diff --git a/app/dashboard/migrations/0188_auto_20211002_0156.py b/app/dashboard/migrations/0188_auto_20211002_0156.py new file mode 100644 index 00000000000..48ce96fef8d --- /dev/null +++ b/app/dashboard/migrations/0188_auto_20211002_0156.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.24 on 2021-10-02 01:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dashboard', '0187_auto_20210928_0700'), + ] + + operations = [ + migrations.AlterField( + model_name='tribemember', + name='status', + field=models.CharField(blank=True, choices=[('accepted', 'accepted'), ('pending', 'pending'), ('rejected', 'rejected')], db_index=True, max_length=20), + ), + ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index 072ba33a2a1..7ebadbca4b9 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -4104,7 +4104,7 @@ def get_fulfilled_bounties(self, network=None): def get_orgs_bounties(self, network=None): network = network or self.get_network() url = f"https://github.com/{self.handle}" - bounties = Bounty.objects.current().filter(network=network, github_url__istartswith=url) + bounties = Bounty.objects.current().filter(network=network, github_url__istartswith=url).cache() return bounties def get_leaderboard_index(self, key='weekly_earners'): @@ -5556,7 +5556,8 @@ class TribeMember(SuperModel): status = models.CharField( max_length=20, choices=MEMBER_STATUS, - blank=True + blank=True, + db_index=True ) why = models.CharField( max_length=20, diff --git a/app/grants/views.py b/app/grants/views.py index 9d00333578e..f54c36f30d3 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -1326,15 +1326,14 @@ def grant_details(request, grant_id, grant_slug): profile = get_profile(request) add_cancel_params = False - try: grant = None try: - grant = Grant.objects.prefetch_related('subscriptions','team_members').get( + grant = Grant.objects.prefetch_related('team_members').get( pk=grant_id, slug=grant_slug ) except Grant.DoesNotExist: - grant = Grant.objects.prefetch_related('subscriptions','team_members').get( + grant = Grant.objects.prefetch_related('team_members').get( pk=grant_id ) @@ -1369,8 +1368,8 @@ def grant_details(request, grant_id, grant_slug): # phantom_funds = grant.phantom_funding.all().cache(timeout=60) # contributors = list(_contributions.distinct('subscription__contributor_profile')) + list(phantom_funds.distinct('profile')) # activity_count = len(cancelled_subscriptions) + len(contributions) - user_subscription = grant.subscriptions.filter(contributor_profile=profile, active=True).first() - user_non_errored_subscription = grant.subscriptions.filter(contributor_profile=profile, active=True, error=False).first() + user_subscription = None + user_non_errored_subscription = None add_cancel_params = user_subscription except Grant.DoesNotExist: raise Http404 diff --git a/app/quests/views.py b/app/quests/views.py index d9f7ccbdd85..b6fcfcebc00 100644 --- a/app/quests/views.py +++ b/app/quests/views.py @@ -219,7 +219,9 @@ def editquest(request, pk=None): def get_package_helper(quest_qs, request): - return [(ele.is_unlocked_for(request.user), ele.is_beaten(request.user), ele.is_within_cooldown_period(request.user), ele) for ele in quest_qs] + #return [(ele.is_unlocked_for(request.user), ele.is_beaten(request.user), ele.is_within_cooldown_period(request.user), ele) for ele in quest_qs] + success = request.user.profile.quest_attempts.filter(success=True).values_list('quest', flat=True) if request.user.is_authenticated else [] + return [(True, ele.pk in success, False, ele) for ele in quest_qs] def index(request): @@ -319,9 +321,9 @@ def index(request): point_value = sum(point_history.values_list('value', flat=True)) print(f" phase4 at {round(time.time(),2)} ") - quests_attempts_per_day = (abs(round(QuestAttempt.objects.count() / - (QuestAttempt.objects.first().created_on - timezone.now()).days, 1)) - if QuestAttempt.objects.count() else 0) + quests_attempts_per_day = (abs(round(QuestAttempt.objects.cache().count() / + (QuestAttempt.objects.cache().first().created_on - timezone.now()).days, 1)) + if QuestAttempt.objects.cache().count() else 0) success_ratio = int(success_count / attempt_count * 100) if attempt_count else 0 # community_created params = { @@ -329,17 +331,17 @@ def index(request): 'quests': quests, 'avg_play_count': round(QuestAttempt.objects.count()/(Quest.objects.count() or 1), 1), 'quests_attempts_total': QuestAttempt.objects.count(), - 'quests_total': Quest.objects.filter(visible=True).count(), + 'quests_total': Quest.objects.cache().filter(visible=True).count(), 'quests_attempts_per_day': quests_attempts_per_day, - 'total_visible_quest_count': Quest.objects.filter(visible=True).count(), - 'gitcoin_created': Quest.objects.filter(visible=True).filter(creator=Profile.objects.filter(handle='gitcoinbot').first()).count(), - 'community_created': Quest.objects.filter(visible=True).exclude(creator=Profile.objects.filter(handle='gitcoinbot').first()).count(), + 'total_visible_quest_count': Quest.objects.cache().filter(visible=True).count(), + 'gitcoin_created': Quest.objects.cache().filter(visible=True).filter(creator=Profile.objects.filter(handle='gitcoinbot').first()).count(), + 'community_created': Quest.objects.cache().filter(visible=True).exclude(creator=Profile.objects.filter(handle='gitcoinbot').first()).count(), 'country_count': 87, - 'email_count': EmailSubscriber.objects.count(), + 'email_count': EmailSubscriber.objects.cache().count(), 'attempt_count': attempt_count, 'success_count': success_count, 'success_ratio': success_ratio, - 'user_count': QuestAttempt.objects.distinct('profile').count(), + 'user_count': QuestAttempt.objects.cache().distinct('profile').count(), 'leaderboard': leaderboard, 'REFER_LINK': f'https://gitcoin.co/quests/?cb=ref:{request.user.profile.ref_code}' if request.user.is_authenticated else None, 'rewards_schedule': rewards_schedule, diff --git a/app/retail/templates/shared/activity.html b/app/retail/templates/shared/activity.html index 082e60f1b24..9e37ccd94be 100644 --- a/app/retail/templates/shared/activity.html +++ b/app/retail/templates/shared/activity.html @@ -47,13 +47,6 @@ {% endfor %} {% endif %} - {% if row.profile.data.type == 'Organization'%} - {% if row.profile.handle not in my_tribes|join:"," %} -
- follow -
- {% endif %} - {% endif %}
diff --git a/app/retail/views.py b/app/retail/views.py index b7bfb95dcfc..a28c6540323 100644 --- a/app/retail/views.py +++ b/app/retail/views.py @@ -741,7 +741,7 @@ def results(request, keyword=None): def get_specific_activities(what, trending_only, user, after_pk, request=None): # create diff filters - activities = Activity.objects.filter(hidden=False).order_by('-created_on').exclude(pin__what__iexact=what) + activities = Activity.objects.filter(hidden=False).order_by('-created_on') network = 'rinkeby' if settings.DEBUG else 'mainnet' filter_network = 'rinkeby' if network == 'mainnet' else 'mainnet' @@ -850,7 +850,6 @@ def get_specific_activities(what, trending_only, user, after_pk, request=None): activities = activities.filter(view_count__gt=view_count_threshold) activities = activities - return activities @@ -893,7 +892,6 @@ def activity(request): 'target': f'/activity?what={what}&trending_only={trending_only}&page={next_page}', 'title': _('Activity Feed'), 'TOKENS': request.user.profile.token_approvals.all() if request.user.is_authenticated and request.user.profile else [], - 'my_tribes': list(request.user.profile.tribe_members.values_list('org__handle',flat=True)) if request.user.is_authenticated else [], } context["activities"] = [a.view_props_for(request.user) for a in page] From 94036ccbd2a92df0588dcb5138841826bcdabed6 Mon Sep 17 00:00:00 2001 From: owocki Date: Fri, 1 Oct 2021 21:13:36 -0600 Subject: [PATCH 6/6] one more index --- .../migrations/0021_auto_20211002_0313.py | 23 +++++++++++++++++++ app/kudos/models.py | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 app/kudos/migrations/0021_auto_20211002_0313.py diff --git a/app/kudos/migrations/0021_auto_20211002_0313.py b/app/kudos/migrations/0021_auto_20211002_0313.py new file mode 100644 index 00000000000..f529b8e3494 --- /dev/null +++ b/app/kudos/migrations/0021_auto_20211002_0313.py @@ -0,0 +1,23 @@ +# Generated by Django 2.2.24 on 2021-10-02 03:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('kudos', '0020_auto_20210924_0616'), + ] + + operations = [ + migrations.AlterField( + model_name='token', + name='hidden', + field=models.BooleanField(db_index=True, default=False, help_text='Hide from marketplace?'), + ), + migrations.AlterField( + model_name='token', + name='num_clones_allowed', + field=models.IntegerField(blank=True, db_index=True, null=True), + ), + ] diff --git a/app/kudos/models.py b/app/kudos/models.py index 33523881e11..528f563e239 100644 --- a/app/kudos/models.py +++ b/app/kudos/models.py @@ -103,7 +103,7 @@ class Meta: # Kudos Struct (also in contract) price_finney = models.IntegerField() - num_clones_allowed = models.IntegerField(null=True, blank=True) + num_clones_allowed = models.IntegerField(null=True, blank=True, db_index=True) num_clones_in_wild = models.IntegerField(null=True, blank=True) num_clones_available_counting_indirect_send = models.IntegerField(blank=True, default=0) @@ -133,7 +133,7 @@ class Meta: contract = models.ForeignKey( 'kudos.Contract', related_name='kudos_contract', on_delete=models.SET_NULL, null=True ) - hidden = models.BooleanField(default=False, help_text=('Hide from marketplace?')) + hidden = models.BooleanField(default=False, help_text=('Hide from marketplace?'), db_index=True) hidden_token_details_page = models.BooleanField(default=False, help_text=('Hide token details page')) send_enabled_for_non_gitcoin_admins = models.BooleanField(default=True) preview_img_mode = models.CharField(max_length=255, default='png')