fix daylight savings times issues in rewards
This commit is contained in:
parent
10a08f28f3
commit
6d55753eed
|
@ -15,7 +15,7 @@ export async function earn ({ name }) {
|
|||
const [{ sum: sumDecimal }] = await models.$queryRaw`
|
||||
SELECT coalesce(sum(total), 0) as sum
|
||||
FROM rewards_days
|
||||
WHERE date_trunc('month', rewards_days.t) = date_trunc('month', (now() - interval '1 month') AT TIME ZONE 'America/Chicago')`
|
||||
WHERE date_trunc('month', rewards_days.t) = date_trunc('month', (now() AT TIME ZONE 'America/Chicago' - interval '1 month'))`
|
||||
|
||||
// XXX primsa will return a Decimal (https://mikemcl.github.io/decimal.js)
|
||||
// because sum of a BIGINT returns a NUMERIC type (https://www.postgresql.org/docs/13/functions-aggregate.html)
|
||||
|
@ -54,7 +54,7 @@ export async function earn ({ name }) {
|
|||
const earners = await models.$queryRaw`
|
||||
SELECT id AS "userId", sum(proportion) as proportion, ROW_NUMBER() OVER (ORDER BY sum(proportion) DESC) as rank
|
||||
FROM user_values_days
|
||||
WHERE date_trunc('month', user_values_days.t) = date_trunc('month', (now() - interval '1 month') AT TIME ZONE 'America/Chicago')
|
||||
WHERE date_trunc('month', user_values_days.t) = date_trunc('month', (now() AT TIME ZONE 'America/Chicago' - interval '1 month'))
|
||||
AND NOT (id = ANY (${SN_NO_REWARDS_IDS}))
|
||||
GROUP BY id
|
||||
ORDER BY proportion DESC
|
||||
|
|
|
@ -54,7 +54,7 @@ export async function territoryRevenue ({ models }) {
|
|||
LEFT JOIN "Item" root ON "Item"."rootId" = root.id
|
||||
JOIN "Sub" ON "Sub"."name" = COALESCE(root."subName", "Item"."subName")
|
||||
LEFT JOIN "ReferralAct" ON "ReferralAct"."itemActId" = "ItemAct".id
|
||||
WHERE date_trunc('day', "ItemAct".created_at AT TIME ZONE 'UTC' AT TIME ZONE 'America/Chicago') = date_trunc('day', (now() - interval '1 day') AT TIME ZONE 'America/Chicago')
|
||||
WHERE date_trunc('day', "ItemAct".created_at AT TIME ZONE 'UTC' AT TIME ZONE 'America/Chicago') = date_trunc('day', (now() AT TIME ZONE 'America/Chicago' - interval '1 day'))
|
||||
AND "ItemAct".act <> 'TIP'
|
||||
AND "Sub".status <> 'STOPPED'
|
||||
) subquery
|
||||
|
|
Loading…
Reference in New Issue