Skip to content

Commit

Permalink
After report
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Jun 14, 2024
1 parent beefc45 commit b77af2f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions bin/export-after.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

set -eu

DB_FILE="$1"
CSV_FILE="$2"

sqlite3 "$DB_FILE" <<EOF
.headers on
.mode csv
.bail on
.output $CSV_FILE
with money as (
select reference, sum(amount) as amount, min(created_at) as paid_at
from payments
group by reference
)
select
users.name as name,
users.email as email,
applications.answers ->> 'support-network' as "support network",
money.amount / 100 as "paid",
money.paid_at as "paid at"
from users
join
applications on applications.user_id = users.id
join
money on money.reference = applications.payment_reference
order by "paid at";
.quit
EOF

0 comments on commit b77af2f

Please sign in to comment.