Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Use Team/~user language more on stats
Browse files Browse the repository at this point in the history
Also adds grand $ total for all time
  • Loading branch information
chadwhitacre committed Aug 31, 2015
1 parent 7e94bc3 commit a7666e1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion tests/py/test_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_about(self):
assert expected in actual

def test_about_stats(self):
expected = "a total of about"
expected = "Gratipay processes"
actual = self.client.GET('/about/stats').body
assert expected in actual

Expand Down
37 changes: 22 additions & 15 deletions www/about/stats.spt
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
from datetime import date

birthday = date(2012, 6, 1)
approximate = lambda x, y=-2: int(round(x, y))
[--------------------------------------------------------]

banner = _("About")
title = _("Stats")
db = website.db
one = website.db.one

age_in_years = (date.today() - birthday).days // 365
volume, nactive = website.db.one("""
volume, nusers = one("""
SELECT volume, nactive
FROM paydays
ORDER BY ts_end DESC
LIMIT 1
""", default=(0.0, 0))
approximate = lambda x: int(round(x, -2))
escrow = db.one("SELECT sum(balance) FROM participants", default=0)
average_payment_amount, average_number_of_payments = db.one("""
nteams = one("SELECT count(*) FROM teams WHERE is_approved IS true AND receiving > 0")
total = one("SELECT sum(amount) FROM exchanges WHERE amount > 0", default=0)
age_in_years = (date.today() - birthday).days // 365
escrow = one("SELECT sum(balance) FROM participants", default=0)
average_payment_amount, average_number_of_payments = one("""

SELECT avg(giving/ngiving_to) AS foo
, round(avg(ngiving_to)) AS bar
Expand All @@ -26,7 +27,6 @@ average_payment_amount, average_number_of_payments = db.one("""
""", back_as=tuple)
average_payment_amount = average_payment_amount or 0
average_number_of_payments = average_number_of_payments or 0

[----------------------------------------------------------] text/html

{% extends "templates/about-basic-info.html" %}
Expand All @@ -41,17 +41,17 @@ average_number_of_payments = average_number_of_payments or 0

{% block content %}

<p>{{ _( "Gratipay is {b}{age}+ years{_b} old and moves a total of about {b}{volume} per week{_b} for about {b}{nactive} users{_b}."
, age=age_in_years
, nactive=approximate(nactive)
<p>{{ _( "Gratipay processes about {b}{volume} per week{_b} for {b}{nteams} Teams{_b} and about {b}{nusers} ~users{_b}."
, volume=format_currency(approximate(volume), 'USD', trailing_zeroes=False)
, nusers=approximate(nusers)
, nteams=nteams
, b='<b>'|safe
, _b='</b>'|safe
) }}</p>

<p>{{ ngettext(
"On average, people who give payments on Gratipay give {b}{amount} to one team{_b}."
, "On average, people who give payments on Gratipay give {b}{amount} each to {number} teams{_b}."
"On average, ~users who give payments on Gratipay give {b}{amount} to one Team{_b}."
, "On average, ~users who give payments on Gratipay give {b}{amount} each to {number} Teams{_b}."

, average_number_of_payments
, amount=format_currency(average_payment_amount, 'USD')
Expand All @@ -60,6 +60,13 @@ average_number_of_payments = average_number_of_payments or 0
, _b='</b>'|safe
) }}</p>

<p>{{ _( "Gratipay has processed about {b}{total}{_b} over {b}{age}+ years{_b}."
, total=format_currency(approximate(total, -3), 'USD', trailing_zeroes=False)
, age=age_in_years
, b='<b>'|safe
, _b='</b>'|safe
) }}</p>

<p>{{ _( "{b}{escrow}{_b} is escrowed within Gratipay."
, escrow=format_currency(escrow, 'USD')
, b='<b>'|safe
Expand All @@ -76,8 +83,8 @@ average_number_of_payments = average_number_of_payments or 0

<div class="chart-wrapper">
<a name="active"></a>
<h2>Active Users</h2>
<p class="note">Users that gave and/or took money on Gratipay (per week)</p>
<h2>Active ~users</h2>
<p class="note">~users that gave and/or took money on Gratipay (per week)</p>
<div class="chart" data-chart="active_users"></div>
<div class="x-axis">weeks</div>
</div>
Expand Down

0 comments on commit a7666e1

Please sign in to comment.