diff --git a/tests/py/test_pages.py b/tests/py/test_pages.py index aa74e11b54..ce83ebc1d8 100644 --- a/tests/py/test_pages.py +++ b/tests/py/test_pages.py @@ -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 diff --git a/www/about/stats.spt b/www/about/stats.spt index b473c7ad8d..71f21021c9 100644 --- a/www/about/stats.spt +++ b/www/about/stats.spt @@ -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 @@ -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" %} @@ -41,17 +41,17 @@ average_number_of_payments = average_number_of_payments or 0 {% block content %} -
{{ _( "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) +
{{ _( "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=''|safe , _b=''|safe ) }}
{{ 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') @@ -60,6 +60,13 @@ average_number_of_payments = average_number_of_payments or 0 , _b=''|safe ) }}
+{{ _( "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=''|safe + , _b=''|safe + ) }}
+{{ _( "{b}{escrow}{_b} is escrowed within Gratipay." , escrow=format_currency(escrow, 'USD') , b=''|safe @@ -76,8 +83,8 @@ average_number_of_payments = average_number_of_payments or 0