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 57b41f5eb4a..cee4f82ab7f 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -4098,7 +4098,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'): @@ -5555,7 +5555,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/dashboard/views.py b/app/dashboard/views.py index 78b1b6b49e2..ce0089f37fe 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): diff --git a/app/grants/views.py b/app/grants/views.py index 1ea56c149b7..6c9fe635f35 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -1329,15 +1329,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 ) @@ -1372,8 +1371,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/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') 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/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

+ +
+
+ + 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 343b1b008b2..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' @@ -849,8 +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 @@ -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] 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