Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allows sorting by clr estimates so that people can easily find where their $$s will go further and focus their attention there #5233

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions app/assets/v2/css/grants/card.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,6 @@
display: flex;
}

.clr {
right: 1.25rem;
}

.clr h2 {
background: #10cd7a;
color: #fff;
border-radius: 3px;
}

.clr p {
font-size: 10px;
}

.grant-item__img {
height: 11rem;
overflow: hidden;
Expand Down
17 changes: 17 additions & 0 deletions app/assets/v2/css/grants/grant.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
.clr {
right: 1.25rem;
}

.clr h2 {
background: #10cd7a;
color: #fff;
border-radius: 3px;
}

.clr p {
font-size: 10px;
}
.header {
background-image: none;
background: linear-gradient(to right top, #0fce7c, #00a5a1, #0077b5, #0046a1, #0d0764);
Expand Down Expand Up @@ -198,6 +211,10 @@
font-size: 12px;
}

#search_form .sort_container .select2-container {
width: 300px !important;
}

#grants_nav{
border-bottom: 1px solid #333333;
text-align: left;
Expand Down
3 changes: 3 additions & 0 deletions app/grants/clr.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ def predict_clr(random_data=False, save_to_db=False):
if save_to_db:
grant.clr_prediction_curve = list(zip(potential_donations, potential_clr))
grant.save()
base = grant.clr_prediction_curve[0][1]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danlipert this adds a third array element, which is how much a specific contribution will net affect the clr match (as opposed to the previous index which is the total if they did)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2019-09-23 at 8 25 28 PM

@owocki Ah this would mean we'd also have to update fund.js cause grant.clr_prediction_curve
is gonna change from [[amount, clr_match]] -> [amount, clr_match_increased_from_current]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think so. the new schema is

[[amount, clr_match, clr_match_increased_from_current]

not

[amount, clr_match_increased_from_current]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh :P lol okie makes sense

grant.clr_prediction_curve = [[ele[0], ele[1], ele[1] - base] for ele in grant.clr_prediction_curve ]
grant.save()

debug_output.append({'grant': grant.id, "clr_prediction_curve": (potential_donations, potential_clr), "grants_clr": grants_clr})
return debug_output
11 changes: 11 additions & 0 deletions app/grants/templates/grants/card/clr_estimate.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% load i18n static humanize grants_extra %}

<div class="clr position-absolute text-center">
<h2 class="font-caption font-weight-bold my-0 p-1">
Round 3 CLR Match estimate: {{ grant.clr_prediction_curve.0.1|floatformat:0|intcomma }} DAI
</h2>
<p class="my-0"> + $1 contrib: +<span id="clr-grant-match">{{ grant.clr_prediction_curve.1.2|floatformat:0|intcomma }}</span> DAI</p>
<p class="my-0"> + $10 contrib: +<span id="clr-grant-match">{{ grant.clr_prediction_curve.2.2|floatformat:0|intcomma }}</span> DAI</p>
<p class="my-0"> + $100 contrib: +<span id="clr-grant-match">{{ grant.clr_prediction_curve.3.2|floatformat:0|intcomma }}</span> DAI</p>
<p class="my-0 mb-2"> + $1k contrib: +<span id="clr-grant-match">{{ grant.clr_prediction_curve.4.2|floatformat:0|intcomma }}</span> DAI</p>
</div>
8 changes: 8 additions & 0 deletions app/grants/templates/grants/card/clr_estimate_prev.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% load i18n static humanize grants_extra %}
{% if grant.clr_matching %}
<div class="clr text-center">
<h2 class="font-caption font-weight-bold my-0 p-1" style="max-width: 105px;">
including {{ grant.clr_matching|floatformat:0 }} DAI from CLR Rounds 1/2
</h2>
</div>
{% endif %}
22 changes: 8 additions & 14 deletions app/grants/templates/grants/card/front.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,23 @@ <h2 class="grant-item__title font-subheader"><a href="{% url 'grants:details' gr
</div>
</div>
</a>
{% if clr_active %}
<div class="clr position-absolute text-center">
<h2 class="font-caption font-weight-bold my-0 p-1">
CLR MATCH <span id="clr-grant-match">{{ grant.clr_prediction_curve.0.1|floatformat:2 }}</span> DAI
</h2>
<p class="my-0">( out of <span id="clr-total">{{ total_clr_pot }}</span> DAI )</p>
</div>
{% endif %}
</div>

<div class="row progress-container mb-4">
<div class="offset-2 col-8 text-center text-xl-left offset-xl-0 col-xl-6 mb-4 mb-xl-0 ">
{% if clr_active %}
{% include 'grants/card/clr_estimate.html' %}
{% else %}
<p class="sub-title mb-0 font-caption">MONTHLY RECURRING</p>
<p class="font-title mb-0 font-weight-bold">
{{ grant.monthly_amount_subscribed|floatformat:0|intcomma }} DAI
</p>
<p class="font-caption {% if grant.clr_matching %} my-2 {% endif %}">
of {{ grant.amount_goal|floatformat:0|intcomma }} DAI goal
</p>

{% endif %}

</div>

<div class="offset-2 col-8 text-center text-xl-left offset-xl-0 col-xl-6">
Expand All @@ -64,16 +62,12 @@ <h2 class="font-caption font-weight-bold my-0 p-1">
{{ grant.amount_received_with_phantom_funds|floatformat:0|intcomma }} DAI
</p>

{% if grant.clr_matching %}
<span class="mr-2 font-caption">+{{ grant.clr_matching|floatformat:0 }} DAI</span>
<img src="{% static "v2/images/grants/clr.svg" %}">
{% endif %}
{% include 'grants/card/clr_estimate_prev.html' %}

</div>
</div>

{% include 'grants/detail/matching.html' %}
<div class="grant-item__state mt-3 row">
<div class="grant-item__state mt-5 row">
<div class="col-6">
{% if grant.active %}
<div class="grant-item__state-active">
Expand Down
36 changes: 18 additions & 18 deletions app/grants/templates/grants/clr_estimate.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{% load static%}
{% if clr_active %}
<div class="clr_estimate {{class}}">
<img src="{% static "v2/images/diamonds_high_fiving.gif" %}" >
<h3>
<span>Clr Match Round {{ clr_round }}</span>
</h3>
<div class="clr_estimate {{class}}">
<img src="{% static "v2/images/diamonds_high_fiving.gif" %}" >
<h3>
<span>Clr Match Round {{ clr_round }}</span>
</h3>

<h4>
<span class="clr_match_prediction">{{ clr_prediction_curve.0|floatformat:2 }}</span>
<span>DAI</span>
of {{ total_clr_pot }} DAI
</h4>
<p class="mb-0">
Your contribution at this moment would increase the CLR Match amount
for this grant by
<strong>
<span class="clr_increase">0.00</span> DAI
</strong>.
</p>
</div>
<h4>
<span class="clr_match_prediction">{{ clr_prediction_curve.0|floatformat:2 }}</span>
<span>DAI</span>
of {{ total_clr_pot }} DAI
</h4>
<p class="mb-0">
Your contribution at this moment would increase the CLR Match amount
for this grant by
<strong>
<span class="clr_increase">0.00</span> DAI
</strong>.
</p>
</div>
{% endif %}
12 changes: 6 additions & 6 deletions app/grants/templates/grants/detail/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,25 +141,27 @@ <h1 class="font-title-xl my-4 font-weight-bold">
</div>
{% endif %}


<div class="row progress-container {% if not is_admin %} mt-4 {% endif %}">
{% if clr_active %}
{% include 'grants/card/clr_estimate.html' %}
{% else %}
<div class="offset-2 col-8 text-center text-xl-left offset-xl-0 col-xl-6 mb-4 mb-xl-0 ">
<p class="sub-title mb-0 font-caption">MONTHLY RECURRING</p>
<p class="font-title-xl mb-0 font-weight-bold">
{{ grant.monthly_amount_subscribed|floatformat:0|intcomma }} DAI
</p>
<p>of {{ grant.amount_goal|floatformat:0|intcomma }} DAI goal</p>
</div>
{% endif %}

<div class="offset-2 col-8 text-center text-xl-left offset-xl-0 col-xl-6">
<p class="sub-title mb-0 font-caption">TOTAL FUNDED</p>
<p class="font-title-xl mb-0 font-weight-bold">
{{ grant.amount_received_with_phantom_funds|floatformat:0|intcomma }} DAI
</p>

{% if grant.clr_matching %}
<span class="mr-2">+{{ grant.clr_matching|floatformat:0 }} DAI</span>
<img src="{% static "v2/images/grants/clr.svg" %}">
{% endif %}
{% include 'grants/card/clr_estimate_prev.html' %}
</div>

</div>
Expand Down Expand Up @@ -293,7 +295,5 @@ <h5 class="font-subheader pb-2">{% trans "Gas Settings" %}</h5>

<span id="grant_contract_owner_address" class="hidden">{{ grant.contract_owner_address }}</span>

{% include 'grants/detail/matching.html' %}

</div>
</div>
15 changes: 11 additions & 4 deletions app/grants/templates/grants/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ <h5>@{{past_partner.profile.handle}}</h5>
</ul>
</div>
<div class="row mt-5">
<div class="col-12 col-md-6 pt-1 text-center text-sm-left pl-sm-0">
<div class="col-12 col-md-4 pt-1 text-center text-sm-left pl-sm-0">
{{ grants_count }} {% trans "Grants available on" %}
<span class="ml-2">
<select name="network" id="network">
Expand All @@ -168,13 +168,20 @@ <h5>@{{past_partner.profile.handle}}</h5>
</select>
</span>
</div>
<div class="col-12 col-md-6 pt-1 font-caption order_by d-md-inline text-center text-sm-right">
<div class="col-12 col-md-8 pt-1 font-caption order_by d-md-inline text-center text-sm-right sort_container">
<div class="heading">{% trans "SORT" %}</div>
<select name="sort_option" id="sort_option">

<option value="match_pledge_amount_1">{% trans "Round 3 $1 Contrib Matching Amount" %}</option>
<option value="match_pledge_amount_10">{% trans "Round 3 $10 Contrib Matching Amount" %}</option>
<option value="match_pledge_amount_100">{% trans "Round 3 $100 Contrib Matching Amount" %}</option>
<option value="match_pledge_amount_1000">{% trans "Round 3 $1k Contrib Matching Amount" %}</option>
<option value="-clr_prediction_curve__0__1">{% trans "Round 3 CLR Match Estimate: Highest" %}</option>
<option value="clr_prediction_curve__0__1">{% trans "Round 3 CLR Match Estimate: Lowest" %}</option>
<option value="-clr_matching">{% trans "Rounds 1 & 2 Total CLR Match: Highest" %}</option>
<option value="clr_matching">{% trans "Rounds 1 & 2 Total CLR Match: Lowest" %}</option>
<option value="-created_on">{% trans "Created: Recent" %}</option>
<option value="created_on">{% trans "Created: Oldest" %}</option>
<option value="-clr_matching">{% trans "CLR Match: Highest" %}</option>
<option value="clr_matching">{% trans "CLR Match: Lowest" %}</option>
<option value="-amount_goal">{% trans "Goal: Highest" %}</option>
<option value="amount_goal">{% trans "Goal: Lowest" %}</option>
<option value="-amount_received">{% trans "Amount Raised: Highest" %}</option>
Expand Down
18 changes: 16 additions & 2 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,29 @@ def grants(request):
"""Handle grants explorer."""
limit = request.GET.get('limit', 6)
page = request.GET.get('page', 1)
sort = request.GET.get('sort_option', '-created_on')
sort = request.GET.get('sort_option', 'match_pledge_amount_1')
network = request.GET.get('network', 'mainnet')
keyword = request.GET.get('keyword', '')
state = request.GET.get('state', 'active')
_grants = None

sort_by_index = None
sort_by_clr_pledge_matching_amount = None
if 'match_pledge_amount_' in sort:
sort_by_clr_pledge_matching_amount = int(sort.split('amount_')[1])
sort_by = 'pk'

if state == 'active':
_grants = Grant.objects.filter(network=network, hidden=False).active().keyword(keyword).order_by(sort)
else:
_grants = Grant.objects.filter(network=network, hidden=False).keyword(keyword).order_by(sort)

clr_prediction_curve_schema_map = {10**x:x+1 for x in range(0, 5)}
if sort_by_clr_pledge_matching_amount in clr_prediction_curve_schema_map.keys():
sort_by_index = clr_prediction_curve_schema_map.get(sort_by_clr_pledge_matching_amount, 0)
field_name = f'clr_prediction_curve__{sort_by_index}__2'
_grants = _grants.order_by(f"-{field_name}")

paginator = Paginator(_grants, limit)
grants = paginator.get_page(page)
partners = MatchPledge.objects.filter(active=True)
Expand Down Expand Up @@ -130,7 +142,8 @@ def grants(request):
'keywords': get_keywords(),
'grant_amount': grant_amount,
'total_clr_pot': total_clr_pot,
'clr_active': True
'clr_active': clr_active,
'sort_by_index': sort_by_index
}

# log this search, it might be useful for matching purposes down the line
Expand Down Expand Up @@ -233,6 +246,7 @@ def grant_details(request, grant_id, grant_slug):
'keywords': get_keywords(),
'activity_count': activity_count,
'contributors': contributors,
'clr_active': clr_active,
}

if add_cancel_params:
Expand Down