Skip to content

Commit d2e56c3

Browse files
committed
Merge branch 'stable'
2 parents 55e6c22 + b8b8552 commit d2e56c3

File tree

14 files changed

+129
-52
lines changed

14 files changed

+129
-52
lines changed

app/app/context.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ def preprocess(request):
7575

7676
user_is_authenticated = request.user.is_authenticated if hasattr(request, 'user') else None
7777
profile = request.user.profile if user_is_authenticated and hasattr(request.user, 'profile') else None
78-
if user_is_authenticated and profile and profile.pk:
78+
user_is_authenticated_and_valid = user_is_authenticated and profile and profile.pk
79+
if user_is_authenticated_and_valid:
7980
# what actions to take?
8081
should_record_join = not profile.last_visit
8182
should_record_visit = not profile.last_visit or profile.last_visit < (
@@ -114,8 +115,7 @@ def preprocess(request):
114115

115116
# town square wall post max length
116117
max_length_offset = abs(((
117-
request.user.profile.created_on
118-
if hasattr(request.user, 'profile') and request.user.is_authenticated else timezone.now()
118+
request.user.profile.created_on if user_is_authenticated_and_valid else timezone.now()
119119
) - timezone.now()).days)
120120
max_length = 600 + max_length_offset
121121

app/app/sitemaps.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ def location(self, item):
196196
'grants': GrantsSitemap,
197197
'hackathons': HackathonEventSiteMap,
198198
'projects': HackathonProjectSiteMap,
199-
'profiles': ProfileSitemap,
200-
'posts': PostSitemap,
199+
# 'profiles': ProfileSitemap,
200+
# 'posts': PostSitemap,
201201
'quests': QuestsSitemap,
202202
'issues': IssueSitemap,
203203
'kudos': KudosSitemap,
204-
'activity': ActivitySitemap,
204+
# 'activity': ActivitySitemap,
205205
'landers': ContributorLandingPageSitemap,
206206
'results': ResultsSitemap,
207207
'static': StaticViewSitemap,

app/assets/v2/js/pages/results.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ $(document).ready(function() {
148148
});
149149
}
150150
});
151+
setTimeout(function() {
152+
$('#grants_results').html(' <iframe src="https://metabase.gitcoin.co/public/question/437a0ed4-bcb7-41eb-af63-e67c0965d200" frameborder="0" width="100%" height="600" allowtransparency></iframe>');
153+
}, 2000);
151154
setTimeout(function() {
152155
$('#leaderboard_nav .nav-link:first-child').click();
153156

@@ -160,7 +163,7 @@ $(document).ready(function() {
160163
</div>
161164
<div class="row py-1">
162165
<div class="col-12 offset-md-0 d-flex justify-content-center align-items-center ">
163-
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">I&#39;m genuinely amazed by the projects in the <a href="https://twitter.com/ArweaveTeam?ref_src=twsrc%5Etfw">@ArweaveTeam</a> <a href="https://twitter.com/gitcoin?ref_src=twsrc%5Etfw">@gitcoin</a> incubator, these are incredible. Wow.</p>&mdash; Lasse Clausen (@lalleclausen) <a href="https://twitter.com/lalleclausen/status/1294320204470722560?ref_src=twsrc%5Etfw">August 14, 2020</a></blockquote>
166+
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">I&#39;m genuinely amazed by the projects in the <a href="https://twitter.com/ArweaveTeam?ref_src=twsrc%5Etfw">@ArweaveTeam</a> <a href="https://twitter.com/gitcoin?ref_src=twsrc%5Etfw">@gitcoin</a> incubator, these are incredible. Wow.</p>&mdash; Lasse Clausen (@lalleclausen) <a href="https://twitter.com/lalleclausen/status/1294320204470722560?ref_src=twsrc%5Etfw">August 14, 2020</a></blockquote>
164167
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
165168
</div>
166169
</div>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Generated by Django 2.2.24 on 2021-10-29 17:48
2+
3+
from django.conf import settings
4+
import django.contrib.postgres.fields.jsonb
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
12+
('dashboard', '0193_tip_value_in_usdt'),
13+
]
14+
15+
operations = [
16+
migrations.AlterModelOptions(
17+
name='searchhistory',
18+
options={'verbose_name_plural': 'Bounties'},
19+
),
20+
migrations.AlterField(
21+
model_name='searchhistory',
22+
name='data',
23+
field=django.contrib.postgres.fields.jsonb.JSONField(db_index=True, default=dict),
24+
),
25+
migrations.AlterField(
26+
model_name='searchhistory',
27+
name='ip_address',
28+
field=models.GenericIPAddressField(blank=True, db_index=True, null=True),
29+
),
30+
migrations.AlterIndexTogether(
31+
name='searchhistory',
32+
index_together={('data', 'search_type', 'ip_address'), ('data', 'search_type', 'ip_address', 'user')},
33+
),
34+
]

app/dashboard/models.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4963,8 +4963,17 @@ class Meta:
49634963

49644964
search_type = models.CharField(max_length=50, db_index=True)
49654965
user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)
4966-
data = JSONField(default=dict)
4967-
ip_address = models.GenericIPAddressField(blank=True, null=True)
4966+
data = JSONField(default=dict, db_index=True)
4967+
ip_address = models.GenericIPAddressField(blank=True, null=True, db_index=True)
4968+
4969+
class Meta:
4970+
"""Define metadata associated with Bounty."""
4971+
4972+
verbose_name_plural = 'Bounties'
4973+
index_together = [
4974+
["data", "search_type", "ip_address"],
4975+
["data", "search_type", "ip_address", "user"],
4976+
]
49684977

49694978

49704979
class BlockedUser(SuperModel):

app/dashboard/tasks.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
from app.utils import get_location_from_ip
1515
from celery import app, group
1616
from celery.utils.log import get_task_logger
17-
from dashboard.models import Activity, Bounty, ObjectView, Profile, UserAction
17+
from dashboard.models import Activity, Bounty, Earning, ObjectView, Profile, TransactionHistory, UserAction
18+
from dashboard.utils import get_tx_status_and_details
19+
from economy.models import EncodeAnything
1820
from marketing.mails import func_name, grant_update_email, send_mail
1921
from proxy.views import proxy_view
2022
from retail.emails import render_share_bounty
@@ -409,3 +411,30 @@ def record_join(self, profile_pk, retry: bool = True) -> None:
409411
Activity.objects.create(profile=profile, activity_type='joined')
410412
except Exception as e:
411413
logger.exception(e)
414+
415+
416+
@app.shared_task(bind=True, max_retries=3)
417+
def save_tx_status_and_details(self, earning_pk, chain='std'):
418+
"""
419+
:param self: Self
420+
:param txid: transaction id
421+
:param network: the network to pass to web3
422+
:param created_on: time used to detect if the tx was dropped
423+
:param chain: chain to pass to web3
424+
:return: None
425+
"""
426+
earning = Earning.objects.filter(pk=earning_pk).first()
427+
txid = earning.txid
428+
network = earning.network
429+
created_on = earning.created_on
430+
status, timestamp, tx = get_tx_status_and_details(txid, network, created_on, chain)
431+
if status not in ['unknown', 'pending']:
432+
tx = tx if tx else {}
433+
TransactionHistory.objects.create(
434+
earning=earning,
435+
status=status,
436+
payload=json.loads(json.dumps(dict(tx), cls=EncodeAnything)),
437+
network=network,
438+
txid=txid,
439+
captured_at=timezone.now(),
440+
)

app/grants/management/commands/payout_round_noncustodial.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ def chunks(lst, n):
296296
# Convert to human units
297297
total_dai_required = total_dai_required_wei / SCALE
298298

299+
# TODO: REMOVE THIS AFTER ROUND 11 PAYOUT
300+
# THIS IS DUE TO SECOND CONTRACT DEPLOY FOR PAYOUT
301+
expected_total_dai_amount = total_dai_required
302+
299303
# Verify that total DAI required (from event logs) equals the expected amount
300304
if math.floor(expected_total_dai_amount) != math.floor(total_dai_required):
301305
print('\n* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *')

app/grants/models/grant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class Meta:
110110
)
111111

112112
def __str__(self):
113-
return f"{self.round_num}"
113+
return f"pk:{self.pk}, round_num: {self.round_num}"
114114

115115
@property
116116
def happening_now(self):

app/grants/templates/grants/detail/_index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ <h3 class="pt-2 pb-3">
112112
{% trans "Latest Contributions" %}
113113
</h3>
114114
<h5 class="mb-5 text-muted" v-if="!transactions.grantTransactions?.length && !loadingTx">{% trans "No Activity for this Grant!" %}</h5>
115-
<div class="px-0" v-if="transactions.grantTransactions?.length && !loadingTx">
115+
<div class="px-0" v-if="transactions.grantTransactions?.length">
116116
<div class="mb-5 pb-2 px-0 mx-sm-0">
117117
<div class="col-12 px-0">
118118
<div id="contributions">

app/grants/views.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,9 +1545,13 @@ def grant_details_contributors(request, grant_id):
15451545
def grant_details_contributions(request, grant_id):
15461546
page = int(request.GET.get('page', 1))
15471547
network = request.GET.get('network', 'mainnet')
1548-
limit = int(request.GET.get('limit', 10))
1548+
limit = int(request.GET.get('limit', 100))
1549+
max_page_size = 300
1550+
if limit > max_page_size:
1551+
limit = max_page_size
1552+
15491553
try:
1550-
grant = Grant.objects.prefetch_related('subscriptions').get(
1554+
grant = Grant.objects.get(
15511555
pk=grant_id
15521556
)
15531557
except Grant.DoesNotExist:
@@ -1558,19 +1562,24 @@ def grant_details_contributions(request, grant_id):
15581562

15591563
_contributions = Contribution.objects.filter(
15601564
subscription__grant=grant,
1561-
subscription__network=network,
1562-
subscription__is_postive_vote=True
1563-
).prefetch_related('subscription', 'subscription__contributor_profile')
1564-
contributions = list(_contributions.order_by('-created_on'))
1565+
)
1566+
1567+
contributions = _contributions.order_by('-created_on')
15651568
# print(contributions)
1566-
all_pages = Paginator(contributions, limit)
1567-
this_page = all_pages.page(page)
1569+
start_index = (page - 1) * limit
1570+
end_index = (page) * limit
1571+
this_page = contributions[start_index:end_index]
15681572
response = dict()
15691573

15701574
all_contributions = []
15711575
for contribution in this_page:
15721576
# print(contribution.subscription)
15731577
# print(contribution.subscription.tx_id)
1578+
subscription = contribution.subscription
1579+
if not subscription.is_postive_vote:
1580+
continue
1581+
if subscription.network != network:
1582+
continue
15741583

15751584
contribution_json = {
15761585
k: getattr(contribution, k) for k in
@@ -1590,10 +1599,7 @@ def grant_details_contributions(request, grant_id):
15901599
all_contributions.append(contribution_json)
15911600

15921601
response['contributions'] = json.loads(json.dumps(all_contributions, default=str))
1593-
response['has_next'] = all_pages.page(page).has_next()
1594-
response['count'] = all_pages.count
1595-
response['num_pages'] = all_pages.num_pages
1596-
response['next_page_number'] = all_pages.page(page).next_page_number() if all_pages.page(page).has_next() else None
1602+
response['next_page_number'] = page + 1
15971603

15981604
return JsonResponse(response)
15991605

0 commit comments

Comments
 (0)