From e60686b662610737fc882f891b31d61dcc91cf1e Mon Sep 17 00:00:00 2001 From: jesush Date: Mon, 18 Jun 2018 21:29:45 -0400 Subject: [PATCH] Added formatting changes, cleanup --- app/dashboard/models.py | 18 +++++++-------- .../templates/emails/quarterly_stats.html | 22 ++++++++++++++----- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/app/dashboard/models.py b/app/dashboard/models.py index d938fdb53ac..781f8f0d02c 100644 --- a/app/dashboard/models.py +++ b/app/dashboard/models.py @@ -1156,15 +1156,11 @@ def get_quarterly_stats(self): bounty for bounty in bounties if bounty.is_hunter(self.handle) and bounty.status == 'done' ] fulfilled_bounties_count = len(fulfilled_bounties) - funded_bounties = [ - bounty for bounty in bounties if bounty.is_funder(self.handle) - ] - funded_bounties_count = len(funded_bounties) + funded_bounties = self.get_funded_bounties() + funded_bounties_count = funded_bounties.count() + from django.db.models import Sum if funded_bounties_count: - total_funded_usd = sum([ - bounty.value_in_usdt if bounty.value_in_usdt else 0 - for bounty in funded_bounties - ]) + total_funded_usd = funded_bounties.all().aggregate(Sum('value_in_usdt')) total_funded_hourly_rate = float(0) #TODO: Explain to the user that we only counted Bounties that developers entered # of hours worked on hourly_rate_bounties_counted = float(0) @@ -1196,8 +1192,10 @@ def get_quarterly_stats(self): user_funded_bounty_developers.append(fulfillment.fulfiller_github_username.lstrip('@')) user_funded_bounty_developers = [*{*user_funded_bounty_developers}] if funded_fulfillments_with_hours_counted: - avg_hourly_rate_per_funded_bounty = float(total_funded_hourly_rate) / float(funded_fulfillments_with_hours_counted) - avg_hours_per_funded_bounty = float(total_funded_hours) / float(funded_fulfillments_with_hours_counted) + avg_hourly_rate_per_funded_bounty = \ + float(total_funded_hourly_rate) / float(funded_fulfillments_with_hours_counted) + avg_hours_per_funded_bounty = \ + float(total_funded_hours) / float(funded_fulfillments_with_hours_counted) else: avg_hourly_rate_per_funded_bounty = 0 avg_hours_per_funded_bounty = 0 diff --git a/app/retail/templates/emails/quarterly_stats.html b/app/retail/templates/emails/quarterly_stats.html index 14af09d4d57..d973782a594 100644 --- a/app/retail/templates/emails/quarterly_stats.html +++ b/app/retail/templates/emails/quarterly_stats.html @@ -230,7 +230,13 @@

An overview of your stats from the last 3 months.

You've boosted your skills in {{ user_no_of_languages }} different areas: - {% for language in user_languages %}{% if forloop.counter == user_no_of_languages %} and {% elif forloop.first %}{% else %},{% endif %} {{ language }}{% endfor %}! + {% for language in user_languages %} + {% if forloop.counter == user_no_of_languages %} + {% if not forloop.first %} and {% endif %} + {% else %}, + {% endif %} + {{ language }} + {% endfor %}!

@@ -245,10 +251,10 @@

You've Been Making Money Moves

An overview of your OSS project's stats from the last 3 months.

-

{{ user_funded_fulfilled_percentage}} %

+

{{ user_funded_fulfilled_percentage }} %

-

Of the {{ user_funded_bounties_count | intcomma }} issue{%if user_funded_bounties_count > 1 %}s{% endif %} that you funded a bounty for, {{ user_num_funded_fulfilled_bounties | intcomma }} were fulfilled -- that's a {{ user_funded_fulfilled_percentage}}% success rate!

+

Of the {{ user_funded_bounties_count | intcomma }} issue{{ user_funded_bounties_count|pluralize }} that you funded a bounty for, {{ user_num_funded_fulfilled_bounties | intcomma }} were fulfilled -- that's a {{ user_funded_fulfilled_percentage}}% success rate!

@@ -256,8 +262,14 @@

An overview of your OSS project's stats from the last 3 months.

{{ user_funded_bounty_developers | length }} contributors

-

The following {{ user_funded_bounty_developers | length }} developers have made contributions to your OSS projects this quarter: - {% for developer in user_funded_bounty_developers %}{% if forloop.counter == user_num_funded_bounty_developers %} & {% elif forloop.first %}{% else %}, {% endif %}@{{ developer }}{% endfor %}

+

The following {{ user_funded_bounty_developers | length }} developer{{ user_funded_bounty_developers|pluralize }} have made contributions to your OSS projects this quarter: + {% for developer in user_funded_bounty_developers %} + {% if forloop.counter == user_num_funded_bounty_developers %} & + {% elif forloop.first %} + {% else %}, + {% endif %} + @{{ developer }} + {% endfor %}