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

Commit

Permalink
Include 2.0 payments in export_history
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpaulk committed May 3, 2017
1 parent 58b514c commit 3da2b9a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions gratipay/utils/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,20 @@ def export_history(participant, year, key, back_as='namedtuple', require_key=Fal
params = dict(username=participant.username, year=year)
out = {}

# FIXME - values from the `payments` table should be included too!
out['given'] = lambda: db.all("""
SELECT tippee, sum(amount) AS amount
SELECT CONCAT('~', tippee) as tippee, sum(amount) AS amount
FROM transfers
WHERE tipper = %(username)s
AND extract(year from timestamp) = %(year)s
GROUP BY tippee
UNION
SELECT team as tippee, sum(amount) AS amount
FROM payments
WHERE participant = %(username)s
AND direction = 'to-team'
AND extract(year from timestamp) = %(year)s
GROUP BY tippee
""", params, back_as=back_as)
out['taken'] = lambda: db.all("""
Expand Down

0 comments on commit 3da2b9a

Please sign in to comment.