Skip to content

Commit ed46b9e

Browse files
committed
Improve performance of fetchDistinctPaymentYearsByUser
This is called from the very niche endpoint /api/transaction/years. The amount > 0 was intended to only check for payments, but in practice this doesn't matter. We can just return the years of acticity for this userId and show no payments for the years it was not used on paybutton. This dramatically speeds up the query (from ~9s to ~100ms on my machine).
1 parent e0dbc87 commit ed46b9e

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

services/transactionService.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,8 +1265,7 @@ export const fetchDistinctPaymentYearsByUser = async (userId: string): Promise<n
12651265
FROM Transaction t
12661266
JOIN Address a ON a.id = t.addressId
12671267
JOIN AddressesOnUserProfiles ap ON ap.addressId = a.id
1268-
WHERE ap.userId = ${userId} AND
1269-
t.amount > 0
1268+
WHERE ap.userId = ${userId}
12701269
ORDER BY year ASC
12711270
`
12721271

0 commit comments

Comments
 (0)