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

Gitcoin Grants CLR Graphs - breakdown of contribution volume over time #5687

Merged
merged 8 commits into from
Jan 8, 2020

Conversation

owocki
Copy link
Contributor

@owocki owocki commented Dec 26, 2019

Description

Adds a grants graph showing the breakdown of fund source over time to each Gitcoin Grant. Details at https://twitter.com/owocki/status/1210242826329632769

Refers/Fixes

User Research/Intution

Testing

on my local
screencapture-localhost-8000-grants-122-austin-griffith-ethereum-rampd-2019-12-30-15_28_46

@owocki owocki changed the title Gitcoin Grants CLR Graphs - breakdown of contribution volume over time DRAFT - Gitcoin Grants CLR Graphs - breakdown of contribution volume over time Dec 26, 2019
@codecov
Copy link

codecov bot commented Dec 26, 2019

Codecov Report

Merging #5687 into master will decrease coverage by 0.02%.
The diff coverage is 6.97%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5687      +/-   ##
==========================================
- Coverage   30.08%   30.05%   -0.03%     
==========================================
  Files         249      249              
  Lines       21455    21652     +197     
  Branches     3113     3213     +100     
==========================================
+ Hits         6454     6508      +54     
- Misses      14725    14863     +138     
- Partials      276      281       +5
Impacted Files Coverage Δ
app/grants/views.py 14.92% <0%> (-0.15%) ⬇️
app/grants/models.py 57.2% <7.69%> (-4.7%) ⬇️
app/dashboard/views.py 12.24% <0%> (ø) ⬆️
...rketing/management/commands/no_applicants_email.py 0% <0%> (ø) ⬆️
app/marketing/mails.py 16.8% <0%> (+3.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a8aa7d9...3f49ec6. Read the comment docs.

@owocki owocki changed the title DRAFT - Gitcoin Grants CLR Graphs - breakdown of contribution volume over time Gitcoin Grants CLR Graphs - breakdown of contribution volume over time Dec 30, 2019
@owocki
Copy link
Contributor Author

owocki commented Dec 30, 2019

@danlipert just finished this up.. moving back to review

</div>
<script>
document.max_graph = {{max_graph}};
document.history = {{history|safe}};
Copy link
Member

@thelostone-mc thelostone-mc Jan 2, 2020

Choose a reason for hiding this comment

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

update it to ?

const max_graph = {{ max_graph }} ;
const history = {{ history|safe }}; 

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm i was anchoring it off the document to give it global scope so i could reuse in the JS file.. let me see if that'll work still

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

if (document.max_graph > 1000) {
increment = 1000;
}
if (document.max_graph > 10000) {
Copy link
Member

Choose a reason for hiding this comment

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

else if

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thatll change the logical execution of this. i could move line 21 above line 18 + add an else if tho

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

google.charts.setOnLoadCallback(drawChart);

function drawChart() {
var target = document.getElementById('grant_chart');
Copy link
Member

Choose a reason for hiding this comment

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

use $('#grant_chart') ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that seems to break the graph. i think that the google chart code doesnt expect jquery elements..

Copy link
Member

Choose a reason for hiding this comment

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

Ah that's cause we are loading it before jquery 😅
no worries

@property
def history_by_month(self):
# gets the history of contributions to this grant month over month so they can be shown o grant details
# returns [["", "Subscription Billing", "New Subscriptions", "One-Time Contributions", "CLR Matching Funds"], ["December 2017", 5534, 2011, 0, 0], ["January 2018", 10396, 0 , 0, 0 ], ... for each monnth in which this grant has contribution history];
Copy link
Member

Choose a reason for hiding this comment

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

remove comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm... are you sure? im trying to get in the habit of documenting my code more..

Copy link
Contributor

Choose a reason for hiding this comment

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

comments are good! I know we have a lot of docstring style comments which I think are overkill and lead to boilerplate copy-and-pasting but I think comments are something we should definitely encourage, especially if we want outside contributors to grok what we are doing more easily and hence be able to effectively dogfood more @thelostone-mc @owocki

Copy link
Member

Choose a reason for hiding this comment

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

alright alright! majority wins :P
the comments stay

subkey = 'New-Recurring'
else:
subkey = 'Recurring-Recurring'
if contrib.subscription.contributor_profile.handle in ['vs77bb', 'gitcoinbot', 'notscottmoore', 'owocki']:
Copy link
Member

Choose a reason for hiding this comment

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

thoughts on moving this to a constant defined above ?
['vs77bb', 'gitcoinbot', 'notscottmoore', 'owocki']`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@thelostone-mc
Copy link
Member

@owocki Also given that folks have pointed out that the right side is empty! Would it make sense to combine this with the activity tab as opposed to being it's own ?

ideally the graph is build form the same data source as activity

@owocki
Copy link
Contributor Author

owocki commented Jan 2, 2020

@owocki Also given that folks have pointed out that the right side is empty! Would it make sense to combine this with the activity tab as opposed to being it's own ?

i dont follow "right side is empty" - what does that mean?

@thelostone-mc
Copy link
Member

derp my bad !
So @androolloyd stated along with a bunch of other folks that the left side is filled with a lot of information while the right side aka tabs look relatively empty

hence the ping asking if it made sense to combine the graph with activity or nah

@owocki
Copy link
Contributor Author

owocki commented Jan 2, 2020

ok thanks; im indifferent to whether it should be its own tab or on the activity tab

Copy link
Contributor Author

@owocki owocki left a comment

Choose a reason for hiding this comment

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

78e793e
turns around aditya's code review.. would lub feedback from others tho

google.charts.setOnLoadCallback(drawChart);

function drawChart() {
var target = document.getElementById('grant_chart');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

that seems to break the graph. i think that the google chart code doesnt expect jquery elements..

if (document.max_graph > 1000) {
increment = 1000;
}
if (document.max_graph > 10000) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

app/assets/v2/js/grants/stats.js Outdated Show resolved Hide resolved
app/assets/v2/js/grants/stats.js Outdated Show resolved Hide resolved
subkey = 'New-Recurring'
else:
subkey = 'Recurring-Recurring'
if contrib.subscription.contributor_profile.handle in ['vs77bb', 'gitcoinbot', 'notscottmoore', 'owocki']:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

app/grants/templates/grants/detail/tabs.html Outdated Show resolved Hide resolved
</div>
<script>
document.max_graph = {{max_graph}};
document.history = {{history|safe}};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Copy link
Contributor

@danlipert danlipert left a comment

Choose a reason for hiding this comment

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

Really stoked for this - just one comment regarding DB queries

# returns [["", "Subscription Billing", "New Subscriptions", "One-Time Contributions", "CLR Matching Funds"], ["December 2017", 5534, 2011, 0, 0], ["January 2018", 10396, 0 , 0, 0 ], ... for each monnth in which this grant has contribution history];
CLR_PAYOUT_HANDLES = ['vs77bb', 'gitcoinbot', 'notscottmoore', 'owocki']
month_to_contribution_numbers = {}
for sub in self.subscriptions.all():
Copy link
Contributor

Choose a reason for hiding this comment

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

prefetch_related('subscription_contribution') will save us a bunch of DB lookups I think. Then filter success=True in python like for contrib in [sc for sc in sub.subscription_contribution if sc.success=True]. What do you think? Cost some CPU but greatly reduces DB lookups so should be faster to execute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hows this? i tested locally 3f49ec6

@danlipert danlipert merged commit f9b7714 into master Jan 8, 2020
@thelostone-mc thelostone-mc deleted the kevin/grants_graphs branch January 8, 2020 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants