Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 182: exclude some transaction types from total funding #302

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions server/lib/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const getCandidateSummary = async ({

// Post MVP we should probably find a way to speed this up.
console.time('getCandidateSummary')
const excludeInterestType = "AND upper(transaction_type) != 'INTEREST'";
// TODO: fix aggregated individual contribution logic
const summary = await db.query(
`
Expand All @@ -58,15 +59,16 @@ const getCandidateSummary = async ({
where contributor_id IS NULl
and canon_committee_sboe_id = $1
)
select sum(amount),
avg(amount),
max(amount),
select sum(adjusted_amount),
avg(adjusted_amount),
max(adjusted_amount),
count(*)::int,
(select aggregated_contributions_count from aggregated_contributions limit 1) as aggregated_contributions_count,
(select aggregated_contributions_sum from aggregated_contributions limit 1) as aggregated_contributions_sum
from contributions
from (select c.*, (CASE WHEN upper(transaction_type) = 'REFUND' THEN amount*-1 ELSE amount END) adjusted_amount from contributions c where canon_committee_sboe_id = $1) contribs
where (
canon_committee_sboe_id = $1
canon_committee_sboe_id = $1
${excludeInterestType}
${safeDateOccurredGteFilter}
${safeDateOccurredLteFilter}
)`,
Expand Down