From beefbb50646ac0c49eec7e8681684a4c46f3fbe8 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Wed, 27 Oct 2021 11:11:12 +0530 Subject: [PATCH 01/14] change str --- app/grants/models/grant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/grants/models/grant.py b/app/grants/models/grant.py index a03c05ac676..14da4386d58 100644 --- a/app/grants/models/grant.py +++ b/app/grants/models/grant.py @@ -110,7 +110,7 @@ class Meta: ) def __str__(self): - return f"{self.round_num}" + return f"pk:{self.pk}, round_num: {self.round_num}" @property def happening_now(self): From 00c2178540863fca2c0f1922d96ca1c870711af0 Mon Sep 17 00:00:00 2001 From: owocki Date: Wed, 27 Oct 2021 08:27:15 -0600 Subject: [PATCH 02/14] increases the size of the s3cmd multipart chunk size so that we dont go over the part limit on full backups --- scripts/backup.bash | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/backup.bash b/scripts/backup.bash index 7d585120041..0d402eecbc8 100755 --- a/scripts/backup.bash +++ b/scripts/backup.bash @@ -28,15 +28,16 @@ export HOST=$(cat app/app/.env | grep "DATABASE_URL" | grep -v REPLICA | awk -F IS_PROD=$(cat app/app/.env | grep ENV | grep prod | wc -l) if [ "$IS_PROD" -eq "1" ]; then # schema - $PG_DUMP gitcoin -U gitcoin -h $HOST --schema-only | s3cmd put - s3://gitcoinbackups/$YEAR/$MONTH/$DAY/create-$BACKUPSTR-$(hostname).sql + $PG_DUMP gitcoin -U gitcoin -h $HOST --schema-only | s3cmd put - s3://gitcoinbackups/$YEAR/$MONTH/$DAY/create-$BACKUPSTR-$(hostname).sql --multipart-chunk-size-mb=500 # lite backup - $PG_DUMP gitcoin -U gitcoin -h $HOST --data-only --exclude-table=marketing_emailevent --exclude-table=dashboard_objectview --exclude-table=marketing_stat --exclude-table=gas_gasprofile --exclude-table=marketing_githubevent --exclude-table=gas_gasguzzler --exclude-table=marketing_slackpresence | s3cmd put - s3://gitcoinbackups/$YEAR/$MONTH/$DAY/litedata-$BACKUPSTR-$(hostname).sql + $PG_DUMP gitcoin -U gitcoin -h $HOST --data-only --exclude-table=marketing_emailevent --exclude-table=dashboard_objectview --exclude-table=marketing_stat --exclude-table=gas_gasprofile --exclude-table=marketing_githubevent --exclude-table=gas_gasguzzler --exclude-table=marketing_slackpresence | s3cmd put - s3://gitcoinbackups/$YEAR/$MONTH/$DAY/litedata-$BACKUPSTR-$(hostname).sql --multipart-chunk-size-mb=500 + # minimal backup - $PG_DUMP gitcoin -U gitcoin -h $HOST --data-only --exclude-table=marketing_emailevent --exclude-table=dashboard_objectview --exclude-table=marketing_stat --exclude-table=gas_gasprofile --exclude-table=marketing_githubevent --exclude-table=gas_gasguzzler --exclude-table=marketing_slackpresence --exclude-table=dashboard_activity --exclude-table=marketing_leaderboardrank --exclude-table=dashboard_activity --exclude-table=perftools_jsonstore --exclude-table=pg_toast --exclude-table=dashboard_searchhistory --exclude-table=townsquare_matchranking --exclude-table=dashboard_useraction --exclude-table=grants_cartactivity --exclude-table=dashboard_profilestathistory --exclude-table=marketing_githubevent --exclude-table=django_session --exclude-table=search_searchresult | s3cmd put - s3://gitcoinbackups/$YEAR/$MONTH/$DAY/minimal-$BACKUPSTR-$(hostname).sql + $PG_DUMP gitcoin -U gitcoin -h $HOST --data-only --exclude-table=marketing_emailevent --exclude-table=dashboard_objectview --exclude-table=marketing_stat --exclude-table=gas_gasprofile --exclude-table=marketing_githubevent --exclude-table=gas_gasguzzler --exclude-table=marketing_slackpresence --exclude-table=dashboard_activity --exclude-table=marketing_leaderboardrank --exclude-table=dashboard_activity --exclude-table=perftools_jsonstore --exclude-table=pg_toast --exclude-table=dashboard_searchhistory --exclude-table=townsquare_matchranking --exclude-table=dashboard_useraction --exclude-table=grants_cartactivity --exclude-table=dashboard_profilestathistory --exclude-table=marketing_githubevent --exclude-table=django_session --exclude-table=search_searchresult | s3cmd put - s3://gitcoinbackups/$YEAR/$MONTH/$DAY/minimal-$BACKUPSTR-$(hostname).sql --multipart-chunk-size-mb=500 # full backup - $PG_DUMP gitcoin -U gitcoin -h $HOST | s3cmd put - s3://gitcoinbackups/$YEAR/$MONTH/$DAY/full-$BACKUPSTR-$(hostname).sql + $PG_DUMP gitcoin -U gitcoin -h $HOST | s3cmd put - s3://gitcoinbackups/$YEAR/$MONTH/$DAY/full-$BACKUPSTR-$(hostname).sql --multipart-chunk-size-mb=500 else From e72b6e73f4c70be6d2a4ee3712417b09ef7b8a42 Mon Sep 17 00:00:00 2001 From: owocki Date: Wed, 27 Oct 2021 09:45:04 -0600 Subject: [PATCH 03/14] fixes slow metabase queries blocking chart load --- app/assets/v2/js/pages/results.js | 3 +++ app/retail/templates/results.html | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/v2/js/pages/results.js b/app/assets/v2/js/pages/results.js index 48b0bcf5a84..feacceab514 100644 --- a/app/assets/v2/js/pages/results.js +++ b/app/assets/v2/js/pages/results.js @@ -148,6 +148,9 @@ $(document).ready(function() { }); } }); + setTimeout(function(){ + $("#grants_results").html(' '); + }, 2000) setTimeout(function() { $('#leaderboard_nav .nav-link:first-child').click(); diff --git a/app/retail/templates/results.html b/app/retail/templates/results.html index 0dd633ae4ad..6dd79d1e6c3 100644 --- a/app/retail/templates/results.html +++ b/app/retail/templates/results.html @@ -206,8 +206,8 @@

Gitcoin Grants: The Growth Engine that Could

-
- +
+ .... loading ....
From 0f68de38b088c5b9a70d784de29f04e8a84ee8e4 Mon Sep 17 00:00:00 2001 From: Graham Dixon Date: Wed, 27 Oct 2021 21:16:17 +0100 Subject: [PATCH 04/14] fix: ensure user exists before checking for profile --- app/app/context.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/app/context.py b/app/app/context.py index 2787ce92c0c..0eb4a7d578f 100644 --- a/app/app/context.py +++ b/app/app/context.py @@ -75,7 +75,8 @@ def preprocess(request): user_is_authenticated = request.user.is_authenticated if hasattr(request, 'user') else None profile = request.user.profile if user_is_authenticated and hasattr(request.user, 'profile') else None - if user_is_authenticated and profile and profile.pk: + user_is_authenticated_and_valid = user_is_authenticated and profile and profile.pk + if user_is_authenticated_and_valid: # what actions to take? should_record_join = not profile.last_visit should_record_visit = not profile.last_visit or profile.last_visit < ( @@ -114,8 +115,7 @@ def preprocess(request): # town square wall post max length max_length_offset = abs((( - request.user.profile.created_on - if hasattr(request.user, 'profile') and request.user.is_authenticated else timezone.now() + request.user.profile.created_on if user_is_authenticated_and_valid else timezone.now() ) - timezone.now()).days) max_length = 600 + max_length_offset From 97578fa1c376e13f43fe7ecefd3b6d9bffc30131 Mon Sep 17 00:00:00 2001 From: Graham Dixon Date: Thu, 28 Oct 2021 02:12:16 +0100 Subject: [PATCH 05/14] fix: fixes linting --- app/assets/v2/js/pages/results.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/v2/js/pages/results.js b/app/assets/v2/js/pages/results.js index feacceab514..eee46422437 100644 --- a/app/assets/v2/js/pages/results.js +++ b/app/assets/v2/js/pages/results.js @@ -148,9 +148,9 @@ $(document).ready(function() { }); } }); - setTimeout(function(){ - $("#grants_results").html(' '); - }, 2000) + setTimeout(function() { + $('#grants_results').html(' '); + }, 2000); setTimeout(function() { $('#leaderboard_nav .nav-link:first-child').click(); @@ -163,7 +163,7 @@ $(document).ready(function() {
- +
From 62a3d072fcb6c87ce1cfe8e42c2542ba81d9f544 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Thu, 28 Oct 2021 11:24:44 +0530 Subject: [PATCH 06/14] push temp fix. THIS SHOULD BE REVERTED --- app/grants/management/commands/payout_round_noncustodial.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/grants/management/commands/payout_round_noncustodial.py b/app/grants/management/commands/payout_round_noncustodial.py index 6018815255a..2fcab3d4740 100644 --- a/app/grants/management/commands/payout_round_noncustodial.py +++ b/app/grants/management/commands/payout_round_noncustodial.py @@ -296,6 +296,10 @@ def chunks(lst, n): # Convert to human units total_dai_required = total_dai_required_wei / SCALE + # TODO: REMOVE THIS AFTER ROUND 11 PAYOUT + # THIS IS DUE TO SECOND CONTRACT DEPLOY FOR PAYOUT + expected_total_dai_amount = total_dai_required + # Verify that total DAI required (from event logs) equals the expected amount if math.floor(expected_total_dai_amount) != math.floor(total_dai_required): print('\n* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *') From 415370721a3192463e67abfdee50fa84dc298039 Mon Sep 17 00:00:00 2001 From: owocki Date: Fri, 29 Oct 2021 07:12:24 -0600 Subject: [PATCH 07/14] updates backup script --- scripts/backup.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/backup.bash b/scripts/backup.bash index 0d402eecbc8..7b2b2cf3600 100755 --- a/scripts/backup.bash +++ b/scripts/backup.bash @@ -31,10 +31,10 @@ if [ "$IS_PROD" -eq "1" ]; then $PG_DUMP gitcoin -U gitcoin -h $HOST --schema-only | s3cmd put - s3://gitcoinbackups/$YEAR/$MONTH/$DAY/create-$BACKUPSTR-$(hostname).sql --multipart-chunk-size-mb=500 # lite backup - $PG_DUMP gitcoin -U gitcoin -h $HOST --data-only --exclude-table=marketing_emailevent --exclude-table=dashboard_objectview --exclude-table=marketing_stat --exclude-table=gas_gasprofile --exclude-table=marketing_githubevent --exclude-table=gas_gasguzzler --exclude-table=marketing_slackpresence | s3cmd put - s3://gitcoinbackups/$YEAR/$MONTH/$DAY/litedata-$BACKUPSTR-$(hostname).sql --multipart-chunk-size-mb=500 + $PG_DUMP gitcoin -U gitcoin -h $HOST --data-only --exclude-table=marketing_emailevent --exclude-table=marketing_emailevent2 --exclude-table=dashboard_objectview --exclude-table=marketing_stat --exclude-table=gas_gasprofile --exclude-table=marketing_githubevent --exclude-table=gas_gasguzzler --exclude-table=marketing_slackpresence | s3cmd put - s3://gitcoinbackups/$YEAR/$MONTH/$DAY/litedata-$BACKUPSTR-$(hostname).sql --multipart-chunk-size-mb=500 # minimal backup - $PG_DUMP gitcoin -U gitcoin -h $HOST --data-only --exclude-table=marketing_emailevent --exclude-table=dashboard_objectview --exclude-table=marketing_stat --exclude-table=gas_gasprofile --exclude-table=marketing_githubevent --exclude-table=gas_gasguzzler --exclude-table=marketing_slackpresence --exclude-table=dashboard_activity --exclude-table=marketing_leaderboardrank --exclude-table=dashboard_activity --exclude-table=perftools_jsonstore --exclude-table=pg_toast --exclude-table=dashboard_searchhistory --exclude-table=townsquare_matchranking --exclude-table=dashboard_useraction --exclude-table=grants_cartactivity --exclude-table=dashboard_profilestathistory --exclude-table=marketing_githubevent --exclude-table=django_session --exclude-table=search_searchresult | s3cmd put - s3://gitcoinbackups/$YEAR/$MONTH/$DAY/minimal-$BACKUPSTR-$(hostname).sql --multipart-chunk-size-mb=500 + $PG_DUMP gitcoin -U gitcoin -h $HOST --data-only --exclude-table=grants_grantstat --exclude-table=marketing_emailevent --exclude-table=marketing_emailevent2 --exclude-table=inbox_notification --exclude-table=dashboard_objectview --exclude-table=marketing_stat --exclude-table=gas_gasprofile --exclude-table=marketing_githubevent --exclude-table=gas_gasguzzler --exclude-table=marketing_slackpresence --exclude-table=dashboard_activity --exclude-table=marketing_leaderboardrank --exclude-table=dashboard_activity --exclude-table=perftools_jsonstore --exclude-table=pg_toast --exclude-table=dashboard_searchhistory --exclude-table=townsquare_matchranking --exclude-table=dashboard_useraction --exclude-table=grants_cartactivity --exclude-table=dashboard_profilestathistory --exclude-table=marketing_githubevent --exclude-table=django_session --exclude-table=search_searchresult | s3cmd put - s3://gitcoinbackups/$YEAR/$MONTH/$DAY/minimal-$BACKUPSTR-$(hostname).sql --multipart-chunk-size-mb=500 # full backup $PG_DUMP gitcoin -U gitcoin -h $HOST | s3cmd put - s3://gitcoinbackups/$YEAR/$MONTH/$DAY/full-$BACKUPSTR-$(hostname).sql --multipart-chunk-size-mb=500 From 58db324e81eda95a372afe167fbbb4c1a0364007 Mon Sep 17 00:00:00 2001 From: Graham Dixon Date: Fri, 29 Oct 2021 20:15:00 +0100 Subject: [PATCH 08/14] fix: adds restart for supervisor gunicorn after deploy (#9632) --- scripts/deploy.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/deploy.bash b/scripts/deploy.bash index 27bf3204243..3bb01d76fe6 100755 --- a/scripts/deploy.bash +++ b/scripts/deploy.bash @@ -96,7 +96,11 @@ if ! [ "$JOBS_NODE" ]; then sleep 1.5 done - if [ $(pgrep -fl "gunicorn: worke" | wc -l) -eq "0" ]; then + # restart gunicorn + if [ $(pgrep -fl "supervisor" | wc -l) -eq "0" ] && [ $(pgrep -fl "gunicorn: worke" | wc -l) -eq "0" ]; then + echo "- RESTART gitcoin-gunicorn" + sudo supervisorctl restart gitcoin_gunicorn + elif [ $(pgrep -fl "gunicorn: worke" | wc -l) -eq "0" ]; then echo "- RESTART gunicorn" sudo systemctl restart gunicorn fi From 5677d814cc8536ecbba33fc6f3134b6a9b6fff36 Mon Sep 17 00:00:00 2001 From: Kevin Owocki Date: Sat, 30 Oct 2021 09:20:48 -0600 Subject: [PATCH 09/14] massively speeds up the grants contribution api call (#9642) * massively speeds up the grants contribution api call * param updates * details ux --- .../templates/grants/detail/_index.html | 2 +- app/grants/views.py | 30 +++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/app/grants/templates/grants/detail/_index.html b/app/grants/templates/grants/detail/_index.html index 126edae7457..f92b1b083a6 100644 --- a/app/grants/templates/grants/detail/_index.html +++ b/app/grants/templates/grants/detail/_index.html @@ -112,7 +112,7 @@

{% trans "Latest Contributions" %}

{% trans "No Activity for this Grant!" %}
-
+
diff --git a/app/grants/views.py b/app/grants/views.py index e47af5f39c7..155ebc6c815 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -1541,9 +1541,13 @@ def grant_details_contributors(request, grant_id): def grant_details_contributions(request, grant_id): page = int(request.GET.get('page', 1)) network = request.GET.get('network', 'mainnet') - limit = int(request.GET.get('limit', 10)) + limit = int(request.GET.get('limit', 100)) + max_page_size = 300 + if limit > max_page_size: + limit = max_page_size + try: - grant = Grant.objects.prefetch_related('subscriptions').get( + grant = Grant.objects.get( pk=grant_id ) except Grant.DoesNotExist: @@ -1554,19 +1558,24 @@ def grant_details_contributions(request, grant_id): _contributions = Contribution.objects.filter( subscription__grant=grant, - subscription__network=network, - subscription__is_postive_vote=True - ).prefetch_related('subscription', 'subscription__contributor_profile') - contributions = list(_contributions.order_by('-created_on')) + ) + + contributions = _contributions.order_by('-created_on') # print(contributions) - all_pages = Paginator(contributions, limit) - this_page = all_pages.page(page) + start_index = (page - 1) * limit + end_index = (page) * limit + this_page = contributions[start_index:end_index] response = dict() all_contributions = [] for contribution in this_page: # print(contribution.subscription) # print(contribution.subscription.tx_id) + subscription = contribution.subscription + if not subscription.is_postive_vote: + continue + if subscription.network != network: + continue contribution_json = { k: getattr(contribution, k) for k in @@ -1586,10 +1595,7 @@ def grant_details_contributions(request, grant_id): all_contributions.append(contribution_json) response['contributions'] = json.loads(json.dumps(all_contributions, default=str)) - response['has_next'] = all_pages.page(page).has_next() - response['count'] = all_pages.count - response['num_pages'] = all_pages.num_pages - response['next_page_number'] = all_pages.page(page).next_page_number() if all_pages.page(page).has_next() else None + response['next_page_number'] = page + 1 return JsonResponse(response) From e0f210bd05e502342c5d6474a4847dd4bbec22b9 Mon Sep 17 00:00:00 2001 From: Kevin Owocki Date: Sat, 30 Oct 2021 09:22:52 -0600 Subject: [PATCH 10/14] search history index fixes (#9643) --- .../migrations/0194_auto_20211029_1748.py | 34 +++++++++++++++++++ app/dashboard/models.py | 13 +++++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 app/dashboard/migrations/0194_auto_20211029_1748.py diff --git a/app/dashboard/migrations/0194_auto_20211029_1748.py b/app/dashboard/migrations/0194_auto_20211029_1748.py new file mode 100644 index 00000000000..3c745b8a657 --- /dev/null +++ b/app/dashboard/migrations/0194_auto_20211029_1748.py @@ -0,0 +1,34 @@ +# Generated by Django 2.2.24 on 2021-10-29 17:48 + +from django.conf import settings +import django.contrib.postgres.fields.jsonb +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('dashboard', '0193_tip_value_in_usdt'), + ] + + operations = [ + migrations.AlterModelOptions( + name='searchhistory', + options={'verbose_name_plural': 'Bounties'}, + ), + migrations.AlterField( + model_name='searchhistory', + name='data', + field=django.contrib.postgres.fields.jsonb.JSONField(db_index=True, default=dict), + ), + migrations.AlterField( + model_name='searchhistory', + name='ip_address', + field=models.GenericIPAddressField(blank=True, db_index=True, null=True), + ), + migrations.AlterIndexTogether( + name='searchhistory', + index_together={('data', 'search_type', 'ip_address'), ('data', 'search_type', 'ip_address', 'user')}, + ), + ] diff --git a/app/dashboard/models.py b/app/dashboard/models.py index a71cb81beb2..4a11308d952 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -4960,8 +4960,17 @@ class Meta: search_type = models.CharField(max_length=50, db_index=True) user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True) - data = JSONField(default=dict) - ip_address = models.GenericIPAddressField(blank=True, null=True) + data = JSONField(default=dict, db_index=True) + ip_address = models.GenericIPAddressField(blank=True, null=True, db_index=True) + + class Meta: + """Define metadata associated with Bounty.""" + + verbose_name_plural = 'Bounties' + index_together = [ + ["data", "search_type", "ip_address"], + ["data", "search_type", "ip_address", "user"], + ] class BlockedUser(SuperModel): From 3f12b16c45ab828263bb8f2251feae930228a64b Mon Sep 17 00:00:00 2001 From: Graham Dixon Date: Sat, 30 Oct 2021 16:23:38 +0100 Subject: [PATCH 11/14] GITC-513: refactor pull_tx_status to work as a celery task (#9606) --- app/dashboard/tasks.py | 31 ++++++++++++++++++- .../management/commands/pull_tx_status.py | 26 +++------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/app/dashboard/tasks.py b/app/dashboard/tasks.py index 548c6030227..f7ad345a017 100644 --- a/app/dashboard/tasks.py +++ b/app/dashboard/tasks.py @@ -14,7 +14,9 @@ from app.utils import get_location_from_ip from celery import app, group from celery.utils.log import get_task_logger -from dashboard.models import Activity, Bounty, ObjectView, Profile, UserAction +from dashboard.models import Activity, Bounty, Earning, ObjectView, Profile, TransactionHistory, UserAction +from dashboard.utils import get_tx_status_and_details +from economy.models import EncodeAnything from marketing.mails import func_name, grant_update_email, send_mail from proxy.views import proxy_view from retail.emails import render_share_bounty @@ -409,3 +411,30 @@ def record_join(self, profile_pk, retry: bool = True) -> None: Activity.objects.create(profile=profile, activity_type='joined') except Exception as e: logger.exception(e) + + +@app.shared_task(bind=True, max_retries=1) +def save_tx_status_and_details(self, earning_pk, txid, network, created_on, chain='std'): + """ + :param self: Self + :param txid: transaction id + :param network: the network to pass to web3 + :param created_on: time used to detect if the tx was dropped + :param chain: chain to pass to web3 + :return: None + """ + earning = Earning.objects.filter(pk=earning_pk).first() + txid = earning.txid + network = earning.network + created_on = earning.created_on + status, timestamp, tx = get_tx_status_and_details(txid, network, created_on, chain) + if status not in ['unknown', 'pending']: + tx = tx if tx else {} + TransactionHistory.objects.create( + earning=earning, + status=status, + payload=json.loads(json.dumps(dict(tx), cls=EncodeAnything)), + network=network, + txid=txid, + captured_at=timezone.now(), + ) diff --git a/app/kudos/management/commands/pull_tx_status.py b/app/kudos/management/commands/pull_tx_status.py index 6b188b96836..d827c2e2544 100644 --- a/app/kudos/management/commands/pull_tx_status.py +++ b/app/kudos/management/commands/pull_tx_status.py @@ -22,9 +22,8 @@ from django.core.management.base import BaseCommand from django.utils import timezone -from dashboard.models import Earning, TransactionHistory -from dashboard.utils import get_tx_status_and_details -from economy.models import EncodeAnything +from dashboard.models import Earning +from dashboard.tasks import save_tx_status_and_details class Command(BaseCommand): @@ -32,22 +31,7 @@ class Command(BaseCommand): help = 'pulls tx statuses and stores them in the DB to be queried later' def handle(self, *args, **options): - earnings = Earning.objects.all().order_by('-pk') + earnings = Earning.objects.filter(history=None).order_by('-pk') for earning in earnings: - if earning.history.count(): - continue - txid = earning.txid - network = earning.network - created_on = earning.created_on - status, timestamp, tx = get_tx_status_and_details(txid, network, created_on) - print(earning.pk, status) - if status not in ['unknown', 'pending']: - tx = tx if tx else {} - TransactionHistory.objects.create( - earning=earning, - status=status, - payload=json.loads(json.dumps(dict(tx), cls=EncodeAnything)), - network=network, - txid=txid, - captured_at=timezone.now(), - ) + # defer the op to celery + save_tx_status_and_details.delay(earning.pk) From c3baa46742f0995dad38505ef43242699904c9d2 Mon Sep 17 00:00:00 2001 From: Graham Dixon Date: Sat, 30 Oct 2021 22:15:25 +0100 Subject: [PATCH 12/14] fix: drop unused positional arguments --- app/dashboard/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/dashboard/tasks.py b/app/dashboard/tasks.py index f7ad345a017..47714b5bb6c 100644 --- a/app/dashboard/tasks.py +++ b/app/dashboard/tasks.py @@ -414,7 +414,7 @@ def record_join(self, profile_pk, retry: bool = True) -> None: @app.shared_task(bind=True, max_retries=1) -def save_tx_status_and_details(self, earning_pk, txid, network, created_on, chain='std'): +def save_tx_status_and_details(self, earning_pk, chain='std'): """ :param self: Self :param txid: transaction id From 8ba6f481e4f2211b2233001deca3feb1ec3b9392 Mon Sep 17 00:00:00 2001 From: Graham Dixon Date: Sun, 31 Oct 2021 01:52:59 +0000 Subject: [PATCH 13/14] fix: ensures an error wont halt the command --- app/dashboard/tasks.py | 2 +- app/kudos/management/commands/pull_tx_status.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/dashboard/tasks.py b/app/dashboard/tasks.py index 47714b5bb6c..348077d2082 100644 --- a/app/dashboard/tasks.py +++ b/app/dashboard/tasks.py @@ -413,7 +413,7 @@ def record_join(self, profile_pk, retry: bool = True) -> None: logger.exception(e) -@app.shared_task(bind=True, max_retries=1) +@app.shared_task(bind=True, max_retries=3) def save_tx_status_and_details(self, earning_pk, chain='std'): """ :param self: Self diff --git a/app/kudos/management/commands/pull_tx_status.py b/app/kudos/management/commands/pull_tx_status.py index d827c2e2544..17db58d53d6 100644 --- a/app/kudos/management/commands/pull_tx_status.py +++ b/app/kudos/management/commands/pull_tx_status.py @@ -34,4 +34,7 @@ def handle(self, *args, **options): earnings = Earning.objects.filter(history=None).order_by('-pk') for earning in earnings: # defer the op to celery - save_tx_status_and_details.delay(earning.pk) + try: + save_tx_status_and_details.delay(earning.pk) + except: + print(f'failed to enqueue: {earning.pk}') From b8b8552050269708d48030e8fa9d9104c978826a Mon Sep 17 00:00:00 2001 From: owocki Date: Sun, 31 Oct 2021 12:13:06 -0600 Subject: [PATCH 14/14] removes offending sitemaps that take the site down --- app/app/sitemaps.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/app/sitemaps.py b/app/app/sitemaps.py index 669052554b9..1ac3e293d88 100644 --- a/app/app/sitemaps.py +++ b/app/app/sitemaps.py @@ -196,12 +196,12 @@ def location(self, item): 'grants': GrantsSitemap, 'hackathons': HackathonEventSiteMap, 'projects': HackathonProjectSiteMap, - 'profiles': ProfileSitemap, - 'posts': PostSitemap, +# 'profiles': ProfileSitemap, +# 'posts': PostSitemap, 'quests': QuestsSitemap, 'issues': IssueSitemap, 'kudos': KudosSitemap, - 'activity': ActivitySitemap, +# 'activity': ActivitySitemap, 'landers': ContributorLandingPageSitemap, 'results': ResultsSitemap, 'static': StaticViewSitemap,