include rewards in top/users
This commit is contained in:
commit
ad40092fcd
|
@ -25,6 +25,28 @@ export function topClause (within) {
|
||||||
return interval
|
return interval
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function earnWithin (within) {
|
||||||
|
let interval = ' AND "Earn".created_at >= $1 - INTERVAL '
|
||||||
|
switch (within) {
|
||||||
|
case 'day':
|
||||||
|
interval += "'1 day'"
|
||||||
|
break
|
||||||
|
case 'week':
|
||||||
|
interval += "'7 days'"
|
||||||
|
break
|
||||||
|
case 'month':
|
||||||
|
interval += "'1 month'"
|
||||||
|
break
|
||||||
|
case 'year':
|
||||||
|
interval += "'1 year'"
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
interval = ''
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return interval
|
||||||
|
}
|
||||||
|
|
||||||
async function authMethods (user, args, { models, me }) {
|
async function authMethods (user, args, { models, me }) {
|
||||||
const accounts = await models.account.findMany({
|
const accounts = await models.account.findMany({
|
||||||
where: {
|
where: {
|
||||||
|
@ -88,14 +110,21 @@ export default {
|
||||||
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
|
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
|
||||||
} else {
|
} else {
|
||||||
users = await models.$queryRaw(`
|
users = await models.$queryRaw(`
|
||||||
SELECT users.name, users.created_at, sum("ItemAct".sats) as amount
|
SELECT name, created_at, sum(sats) as amount
|
||||||
FROM "ItemAct"
|
FROM
|
||||||
JOIN "Item" on "ItemAct"."itemId" = "Item".id
|
((SELECT users.name, users.created_at, "ItemAct".sats as sats
|
||||||
JOIN users on "Item"."userId" = users.id
|
FROM "ItemAct"
|
||||||
WHERE act <> 'BOOST' AND "ItemAct"."userId" <> users.id AND "ItemAct".created_at <= $1
|
JOIN "Item" on "ItemAct"."itemId" = "Item".id
|
||||||
${topClause(within)}
|
JOIN users on "Item"."userId" = users.id
|
||||||
GROUP BY users.id, users.name
|
WHERE act <> 'BOOST' AND "ItemAct"."userId" <> users.id AND "ItemAct".created_at <= $1
|
||||||
ORDER BY amount DESC NULLS LAST, users.created_at DESC
|
${topClause(within)})
|
||||||
|
UNION ALL
|
||||||
|
(SELECT users.name, users.created_at, "Earn".msats/1000 as sats
|
||||||
|
FROM "Earn"
|
||||||
|
JOIN users on users.id = "Earn"."userId"
|
||||||
|
WHERE "Earn".msats > 0 ${earnWithin(within)})) u
|
||||||
|
GROUP BY name, created_at
|
||||||
|
ORDER BY amount DESC NULLS LAST, created_at DESC
|
||||||
OFFSET $2
|
OFFSET $2
|
||||||
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
|
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,7 @@ function ZoomableImage ({ src, topLevel, ...props }) {
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
if (mediaStyle.cursor === 'zoom-in') {
|
if (mediaStyle.cursor === 'zoom-in') {
|
||||||
setMediaStyle({
|
setMediaStyle({
|
||||||
|
width: '100%',
|
||||||
cursor: 'zoom-out'
|
cursor: 'zoom-out'
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue