upgrade to prisma 3
This commit is contained in:
parent
5a4f63b1d5
commit
672853a7ea
|
@ -65,7 +65,7 @@ export default {
|
||||||
Query: {
|
Query: {
|
||||||
registrationGrowth: async (parent, { when }, { models }) => {
|
registrationGrowth: async (parent, { when }, { models }) => {
|
||||||
if (when !== 'day') {
|
if (when !== 'day') {
|
||||||
return await models.$queryRaw(`
|
return await models.$queryRawUnsafe(`
|
||||||
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
||||||
json_build_object('name', 'referrals', 'value', sum(referrals)),
|
json_build_object('name', 'referrals', 'value', sum(referrals)),
|
||||||
json_build_object('name', 'organic', 'value', sum(organic))
|
json_build_object('name', 'organic', 'value', sum(organic))
|
||||||
|
@ -76,7 +76,7 @@ export default {
|
||||||
ORDER BY time ASC`)
|
ORDER BY time ASC`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return await models.$queryRaw(
|
return await models.$queryRawUnsafe(
|
||||||
`${withClause(when)}
|
`${withClause(when)}
|
||||||
SELECT time, json_build_array(
|
SELECT time, json_build_array(
|
||||||
json_build_object('name', 'referrals', 'value', count("referrerId")),
|
json_build_object('name', 'referrals', 'value', count("referrerId")),
|
||||||
|
@ -89,7 +89,7 @@ export default {
|
||||||
},
|
},
|
||||||
spenderGrowth: async (parent, { when }, { models }) => {
|
spenderGrowth: async (parent, { when }, { models }) => {
|
||||||
if (when !== 'day') {
|
if (when !== 'day') {
|
||||||
return await models.$queryRaw(`
|
return await models.$queryRawUnsafe(`
|
||||||
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
||||||
json_build_object('name', 'any', 'value', floor(avg("any"))),
|
json_build_object('name', 'any', 'value', floor(avg("any"))),
|
||||||
json_build_object('name', 'jobs', 'value', floor(avg(jobs))),
|
json_build_object('name', 'jobs', 'value', floor(avg(jobs))),
|
||||||
|
@ -104,7 +104,7 @@ export default {
|
||||||
ORDER BY time ASC`)
|
ORDER BY time ASC`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return await models.$queryRaw(
|
return await models.$queryRawUnsafe(
|
||||||
`${withClause(when)}
|
`${withClause(when)}
|
||||||
SELECT time, json_build_array(
|
SELECT time, json_build_array(
|
||||||
json_build_object('name', 'any', 'value', count(DISTINCT "userId")),
|
json_build_object('name', 'any', 'value', count(DISTINCT "userId")),
|
||||||
|
@ -128,7 +128,7 @@ export default {
|
||||||
},
|
},
|
||||||
itemGrowth: async (parent, { when }, { models }) => {
|
itemGrowth: async (parent, { when }, { models }) => {
|
||||||
if (when !== 'day') {
|
if (when !== 'day') {
|
||||||
return await models.$queryRaw(`
|
return await models.$queryRawUnsafe(`
|
||||||
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
||||||
json_build_object('name', 'posts', 'value', sum(posts)),
|
json_build_object('name', 'posts', 'value', sum(posts)),
|
||||||
json_build_object('name', 'comments', 'value', sum(comments)),
|
json_build_object('name', 'comments', 'value', sum(comments)),
|
||||||
|
@ -140,7 +140,7 @@ export default {
|
||||||
ORDER BY time ASC`)
|
ORDER BY time ASC`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return await models.$queryRaw(
|
return await models.$queryRawUnsafe(
|
||||||
`${withClause(when)}
|
`${withClause(when)}
|
||||||
SELECT time, json_build_array(
|
SELECT time, json_build_array(
|
||||||
json_build_object('name', 'comments', 'value', count("parentId")),
|
json_build_object('name', 'comments', 'value', count("parentId")),
|
||||||
|
@ -154,7 +154,7 @@ export default {
|
||||||
},
|
},
|
||||||
spendingGrowth: async (parent, { when }, { models }) => {
|
spendingGrowth: async (parent, { when }, { models }) => {
|
||||||
if (when !== 'day') {
|
if (when !== 'day') {
|
||||||
return await models.$queryRaw(`
|
return await models.$queryRawUnsafe(`
|
||||||
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
||||||
json_build_object('name', 'jobs', 'value', sum(jobs)),
|
json_build_object('name', 'jobs', 'value', sum(jobs)),
|
||||||
json_build_object('name', 'boost', 'value', sum(boost)),
|
json_build_object('name', 'boost', 'value', sum(boost)),
|
||||||
|
@ -168,7 +168,7 @@ export default {
|
||||||
ORDER BY time ASC`)
|
ORDER BY time ASC`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return await models.$queryRaw(
|
return await models.$queryRawUnsafe(
|
||||||
`${withClause(when)}
|
`${withClause(when)}
|
||||||
SELECT time, json_build_array(
|
SELECT time, json_build_array(
|
||||||
json_build_object('name', 'jobs', 'value', coalesce(floor(sum(CASE WHEN act = 'STREAM' THEN msats ELSE 0 END)/1000),0)),
|
json_build_object('name', 'jobs', 'value', coalesce(floor(sum(CASE WHEN act = 'STREAM' THEN msats ELSE 0 END)/1000),0)),
|
||||||
|
@ -191,7 +191,7 @@ export default {
|
||||||
},
|
},
|
||||||
stackerGrowth: async (parent, { when }, { models }) => {
|
stackerGrowth: async (parent, { when }, { models }) => {
|
||||||
if (when !== 'day') {
|
if (when !== 'day') {
|
||||||
return await models.$queryRaw(`
|
return await models.$queryRawUnsafe(`
|
||||||
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
||||||
json_build_object('name', 'any', 'value', floor(avg("any"))),
|
json_build_object('name', 'any', 'value', floor(avg("any"))),
|
||||||
json_build_object('name', 'posts', 'value', floor(avg(posts))),
|
json_build_object('name', 'posts', 'value', floor(avg(posts))),
|
||||||
|
@ -205,7 +205,7 @@ export default {
|
||||||
ORDER BY time ASC`)
|
ORDER BY time ASC`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return await models.$queryRaw(
|
return await models.$queryRawUnsafe(
|
||||||
`${withClause(when)}
|
`${withClause(when)}
|
||||||
SELECT time, json_build_array(
|
SELECT time, json_build_array(
|
||||||
json_build_object('name', 'any', 'value', count(distinct user_id)),
|
json_build_object('name', 'any', 'value', count(distinct user_id)),
|
||||||
|
@ -233,7 +233,7 @@ export default {
|
||||||
},
|
},
|
||||||
stackingGrowth: async (parent, { when }, { models }) => {
|
stackingGrowth: async (parent, { when }, { models }) => {
|
||||||
if (when !== 'day') {
|
if (when !== 'day') {
|
||||||
return await models.$queryRaw(`
|
return await models.$queryRawUnsafe(`
|
||||||
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
SELECT date_trunc('${timeUnit(when)}', day) as time, json_build_array(
|
||||||
json_build_object('name', 'rewards', 'value', sum(rewards)),
|
json_build_object('name', 'rewards', 'value', sum(rewards)),
|
||||||
json_build_object('name', 'posts', 'value', sum(posts)),
|
json_build_object('name', 'posts', 'value', sum(posts)),
|
||||||
|
@ -246,7 +246,7 @@ export default {
|
||||||
ORDER BY time ASC`)
|
ORDER BY time ASC`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return await models.$queryRaw(
|
return await models.$queryRawUnsafe(
|
||||||
`${withClause(when)}
|
`${withClause(when)}
|
||||||
SELECT time, json_build_array(
|
SELECT time, json_build_array(
|
||||||
json_build_object('name', 'rewards', 'value', coalesce(floor(sum(airdrop)/1000),0)),
|
json_build_object('name', 'rewards', 'value', coalesce(floor(sum(airdrop)/1000),0)),
|
||||||
|
|
|
@ -52,12 +52,12 @@ async function comments (me, models, id, sort) {
|
||||||
|
|
||||||
const filter = await commentFilterClause(me, models)
|
const filter = await commentFilterClause(me, models)
|
||||||
if (me) {
|
if (me) {
|
||||||
const [{ item_comments_with_me: comments }] = await models.$queryRaw(
|
const [{ item_comments_with_me: comments }] = await models.$queryRawUnsafe(
|
||||||
'SELECT item_comments_with_me($1, $2, $3, $4, $5)', Number(id), Number(me.id), COMMENT_DEPTH_LIMIT, filter, orderBy)
|
'SELECT item_comments_with_me($1, $2, $3, $4, $5)', Number(id), Number(me.id), COMMENT_DEPTH_LIMIT, filter, orderBy)
|
||||||
return comments
|
return comments
|
||||||
}
|
}
|
||||||
|
|
||||||
const [{ item_comments: comments }] = await models.$queryRaw(
|
const [{ item_comments: comments }] = await models.$queryRawUnsafe(
|
||||||
'SELECT item_comments($1, $2, $3, $4)', Number(id), COMMENT_DEPTH_LIMIT, filter, orderBy)
|
'SELECT item_comments($1, $2, $3, $4)', Number(id), COMMENT_DEPTH_LIMIT, filter, orderBy)
|
||||||
return comments
|
return comments
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ function typeClause (type) {
|
||||||
// joining does not preserve the order of the inner query
|
// joining does not preserve the order of the inner query
|
||||||
async function itemQueryWithMeta ({ me, models, query, orderBy = '' }, ...args) {
|
async function itemQueryWithMeta ({ me, models, query, orderBy = '' }, ...args) {
|
||||||
if (!me) {
|
if (!me) {
|
||||||
return await models.$queryRaw(`
|
return await models.$queryRawUnsafe(`
|
||||||
SELECT "Item".*, to_json(users.*) as user
|
SELECT "Item".*, to_json(users.*) as user
|
||||||
FROM (
|
FROM (
|
||||||
${query}
|
${query}
|
||||||
|
@ -219,7 +219,7 @@ async function itemQueryWithMeta ({ me, models, query, orderBy = '' }, ...args)
|
||||||
JOIN users ON "Item"."userId" = users.id
|
JOIN users ON "Item"."userId" = users.id
|
||||||
${orderBy}`, ...args)
|
${orderBy}`, ...args)
|
||||||
} else {
|
} else {
|
||||||
return await models.$queryRaw(`
|
return await models.$queryRawUnsafe(`
|
||||||
SELECT "Item".*, to_json(users.*) as user, COALESCE("ItemAct"."meMsats", 0) as "meMsats",
|
SELECT "Item".*, to_json(users.*) as user, COALESCE("ItemAct"."meMsats", 0) as "meMsats",
|
||||||
COALESCE("ItemAct"."meDontLike", false) as "meDontLike", "Bookmark"."itemId" IS NOT NULL AS "meBookmark",
|
COALESCE("ItemAct"."meDontLike", false) as "meDontLike", "Bookmark"."itemId" IS NOT NULL AS "meBookmark",
|
||||||
"ThreadSubscription"."itemId" IS NOT NULL AS "meSubscription"
|
"ThreadSubscription"."itemId" IS NOT NULL AS "meSubscription"
|
||||||
|
@ -272,7 +272,7 @@ export default {
|
||||||
itemRepetition: async (parent, { parentId }, { me, models }) => {
|
itemRepetition: async (parent, { parentId }, { me, models }) => {
|
||||||
if (!me) return 0
|
if (!me) return 0
|
||||||
// how many of the parents starting at parentId belong to me
|
// how many of the parents starting at parentId belong to me
|
||||||
const [{ item_spam: count }] = await models.$queryRaw(`SELECT item_spam($1, $2, '${ITEM_SPAM_INTERVAL}')`,
|
const [{ item_spam: count }] = await models.$queryRawUnsafe(`SELECT item_spam($1, $2, '${ITEM_SPAM_INTERVAL}')`,
|
||||||
Number(parentId), Number(me.id))
|
Number(parentId), Number(me.id))
|
||||||
|
|
||||||
return count
|
return count
|
||||||
|
@ -621,7 +621,7 @@ export default {
|
||||||
throw new GraphQLError('item does not belong to you', { extensions: { code: 'FORBIDDEN' } })
|
throw new GraphQLError('item does not belong to you', { extensions: { code: 'FORBIDDEN' } })
|
||||||
}
|
}
|
||||||
const [item] = await serialize(models,
|
const [item] = await serialize(models,
|
||||||
models.$queryRaw(`${SELECT} FROM update_poll($1, $2, $3, $4, $5, $6, $7) AS "Item"`,
|
models.$queryRawUnsafe(`${SELECT} FROM update_poll($1, $2, $3, $4, $5, $6, $7) AS "Item"`,
|
||||||
sub || 'bitcoin', Number(id), title, text, Number(boost || 0), options, Number(fwdUser?.id)))
|
sub || 'bitcoin', Number(id), title, text, Number(boost || 0), options, Number(fwdUser?.id)))
|
||||||
|
|
||||||
await createMentions(item, models)
|
await createMentions(item, models)
|
||||||
|
@ -629,7 +629,7 @@ export default {
|
||||||
return item
|
return item
|
||||||
} else {
|
} else {
|
||||||
const [item] = await serialize(models,
|
const [item] = await serialize(models,
|
||||||
models.$queryRaw(`${SELECT} FROM create_poll($1, $2, $3, $4, $5, $6, $7, $8, '${ITEM_SPAM_INTERVAL}') AS "Item"`,
|
models.$queryRawUnsafe(`${SELECT} FROM create_poll($1, $2, $3, $4, $5, $6, $7, $8, '${ITEM_SPAM_INTERVAL}') AS "Item"`,
|
||||||
sub || 'bitcoin', title, text, 1, Number(boost || 0), Number(me.id), options, Number(fwdUser?.id)))
|
sub || 'bitcoin', title, text, 1, Number(boost || 0), Number(me.id), options, Number(fwdUser?.id)))
|
||||||
|
|
||||||
await createMentions(item, models)
|
await createMentions(item, models)
|
||||||
|
@ -658,12 +658,12 @@ export default {
|
||||||
throw new GraphQLError('item does not belong to you', { extensions: { code: 'FORBIDDEN' } })
|
throw new GraphQLError('item does not belong to you', { extensions: { code: 'FORBIDDEN' } })
|
||||||
}
|
}
|
||||||
([item] = await serialize(models,
|
([item] = await serialize(models,
|
||||||
models.$queryRaw(
|
models.$queryRawUnsafe(
|
||||||
`${SELECT} FROM update_job($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) AS "Item"`,
|
`${SELECT} FROM update_job($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) AS "Item"`,
|
||||||
Number(id), title, url, text, Number(maxBid), company, loc, remote, Number(logo), status)))
|
Number(id), title, url, text, Number(maxBid), company, loc, remote, Number(logo), status)))
|
||||||
} else {
|
} else {
|
||||||
([item] = await serialize(models,
|
([item] = await serialize(models,
|
||||||
models.$queryRaw(
|
models.$queryRawUnsafe(
|
||||||
`${SELECT} FROM create_job($1, $2, $3, $4, $5, $6, $7, $8, $9) AS "Item"`,
|
`${SELECT} FROM create_job($1, $2, $3, $4, $5, $6, $7, $8, $9) AS "Item"`,
|
||||||
title, url, text, Number(me.id), Number(maxBid), company, loc, remote, Number(logo))))
|
title, url, text, Number(me.id), Number(maxBid), company, loc, remote, Number(logo))))
|
||||||
}
|
}
|
||||||
|
@ -678,7 +678,7 @@ export default {
|
||||||
// fetch user to get up-to-date name
|
// fetch user to get up-to-date name
|
||||||
const user = await models.user.findUnique({ where: { id: me.id } })
|
const user = await models.user.findUnique({ where: { id: me.id } })
|
||||||
|
|
||||||
const parents = await models.$queryRaw(
|
const parents = await models.$queryRawUnsafe(
|
||||||
'SELECT DISTINCT p."userId" FROM "Item" i JOIN "Item" p ON p.path @> i.path WHERE i.id = $1 and p."userId" <> $2',
|
'SELECT DISTINCT p."userId" FROM "Item" i JOIN "Item" p ON p.path @> i.path WHERE i.id = $1 and p."userId" <> $2',
|
||||||
Number(item.parentId), Number(me.id))
|
Number(item.parentId), Number(me.id))
|
||||||
Promise.allSettled(
|
Promise.allSettled(
|
||||||
|
@ -702,7 +702,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
await serialize(models,
|
await serialize(models,
|
||||||
models.$queryRaw(`${SELECT} FROM poll_vote($1, $2) AS "Item"`,
|
models.$queryRawUnsafe(`${SELECT} FROM poll_vote($1, $2) AS "Item"`,
|
||||||
Number(id), Number(me.id)))
|
Number(id), Number(me.id)))
|
||||||
|
|
||||||
return id
|
return id
|
||||||
|
@ -716,7 +716,7 @@ export default {
|
||||||
await ssValidate(amountSchema, { amount: sats })
|
await ssValidate(amountSchema, { amount: sats })
|
||||||
|
|
||||||
// disallow self tips
|
// disallow self tips
|
||||||
const [item] = await models.$queryRaw(`
|
const [item] = await models.$queryRawUnsafe(`
|
||||||
${SELECT}
|
${SELECT}
|
||||||
FROM "Item"
|
FROM "Item"
|
||||||
WHERE id = $1 AND "userId" = $2`, Number(id), me.id)
|
WHERE id = $1 AND "userId" = $2`, Number(id), me.id)
|
||||||
|
@ -747,7 +747,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// disallow self down votes
|
// disallow self down votes
|
||||||
const [item] = await models.$queryRaw(`
|
const [item] = await models.$queryRawUnsafe(`
|
||||||
${SELECT}
|
${SELECT}
|
||||||
FROM "Item"
|
FROM "Item"
|
||||||
WHERE id = $1 AND "userId" = $2`, Number(id), me.id)
|
WHERE id = $1 AND "userId" = $2`, Number(id), me.id)
|
||||||
|
@ -858,8 +858,8 @@ export default {
|
||||||
if (!me) return 0
|
if (!me) return 0
|
||||||
if (typeof item.meMsats === 'number') return msatsToSats(item.meMsats)
|
if (typeof item.meMsats === 'number') return msatsToSats(item.meMsats)
|
||||||
|
|
||||||
const { sum: { msats } } = await models.itemAct.aggregate({
|
const { _sum: { msats } } = await models.itemAct.aggregate({
|
||||||
sum: {
|
_sum: {
|
||||||
msats: true
|
msats: true
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
|
@ -1034,7 +1034,7 @@ export const updateItem = async (parent, { id, data: { sub, title, url, text, bo
|
||||||
text = await proxyImages(text)
|
text = await proxyImages(text)
|
||||||
|
|
||||||
const [item] = await serialize(models,
|
const [item] = await serialize(models,
|
||||||
models.$queryRaw(
|
models.$queryRawUnsafe(
|
||||||
`${SELECT} FROM update_item($1, $2, $3, $4, $5, $6, $7, $8) AS "Item"`,
|
`${SELECT} FROM update_item($1, $2, $3, $4, $5, $6, $7, $8) AS "Item"`,
|
||||||
old.parentId ? null : sub || 'bitcoin', Number(id), title, url, text,
|
old.parentId ? null : sub || 'bitcoin', Number(id), title, url, text,
|
||||||
Number(boost || 0), bounty ? Number(bounty) : null, Number(fwdUser?.id)))
|
Number(boost || 0), bounty ? Number(bounty) : null, Number(fwdUser?.id)))
|
||||||
|
@ -1070,7 +1070,7 @@ const createItem = async (parent, { sub, title, url, text, boost, forward, bount
|
||||||
|
|
||||||
const [item] = await serialize(
|
const [item] = await serialize(
|
||||||
models,
|
models,
|
||||||
models.$queryRaw(
|
models.$queryRawUnsafe(
|
||||||
`${SELECT} FROM create_item($1, $2, $3, $4, $5, $6, $7, $8, $9, '${ITEM_SPAM_INTERVAL}') AS "Item"`,
|
`${SELECT} FROM create_item($1, $2, $3, $4, $5, $6, $7, $8, $9, '${ITEM_SPAM_INTERVAL}') AS "Item"`,
|
||||||
parentId ? null : sub || 'bitcoin',
|
parentId ? null : sub || 'bitcoin',
|
||||||
title,
|
title,
|
||||||
|
|
|
@ -194,7 +194,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// we do all this crazy subquery stuff to make 'reward' islands
|
// we do all this crazy subquery stuff to make 'reward' islands
|
||||||
const notifications = await models.$queryRaw(
|
const notifications = await models.$queryRawUnsafe(
|
||||||
`SELECT MAX(id) AS id, MAX("sortTime") AS "sortTime", sum("earnedSats") AS "earnedSats", type,
|
`SELECT MAX(id) AS id, MAX("sortTime") AS "sortTime", sum("earnedSats") AS "earnedSats", type,
|
||||||
MIN("sortTime") AS "minSortTime"
|
MIN("sortTime") AS "minSortTime"
|
||||||
FROM
|
FROM
|
||||||
|
@ -286,7 +286,7 @@ export default {
|
||||||
},
|
},
|
||||||
Earn: {
|
Earn: {
|
||||||
sources: async (n, args, { me, models }) => {
|
sources: async (n, args, { me, models }) => {
|
||||||
const [sources] = await models.$queryRaw(`
|
const [sources] = await models.$queryRawUnsafe(`
|
||||||
SELECT
|
SELECT
|
||||||
FLOOR(sum(msats) FILTER(WHERE type = 'POST') / 1000) AS posts,
|
FLOOR(sum(msats) FILTER(WHERE type = 'POST') / 1000) AS posts,
|
||||||
FLOOR(sum(msats) FILTER(WHERE type = 'COMMENT') / 1000) AS comments,
|
FLOOR(sum(msats) FILTER(WHERE type = 'COMMENT') / 1000) AS comments,
|
||||||
|
|
|
@ -8,21 +8,21 @@ export default {
|
||||||
throw new GraphQLError('you must be logged in', { extensions: { code: 'UNAUTHENTICATED' } })
|
throw new GraphQLError('you must be logged in', { extensions: { code: 'UNAUTHENTICATED' } })
|
||||||
}
|
}
|
||||||
|
|
||||||
const [{ totalSats }] = await models.$queryRaw(`
|
const [{ totalSats }] = await models.$queryRawUnsafe(`
|
||||||
SELECT COALESCE(FLOOR(sum(msats) / 1000), 0) as "totalSats"
|
SELECT COALESCE(FLOOR(sum(msats) / 1000), 0) as "totalSats"
|
||||||
FROM "ReferralAct"
|
FROM "ReferralAct"
|
||||||
WHERE ${intervalClause(when, 'ReferralAct', true)}
|
WHERE ${intervalClause(when, 'ReferralAct', true)}
|
||||||
"ReferralAct"."referrerId" = $1
|
"ReferralAct"."referrerId" = $1
|
||||||
`, Number(me.id))
|
`, Number(me.id))
|
||||||
|
|
||||||
const [{ totalReferrals }] = await models.$queryRaw(`
|
const [{ totalReferrals }] = await models.$queryRawUnsafe(`
|
||||||
SELECT count(*) as "totalReferrals"
|
SELECT count(*) as "totalReferrals"
|
||||||
FROM users
|
FROM users
|
||||||
WHERE ${intervalClause(when, 'users', true)}
|
WHERE ${intervalClause(when, 'users', true)}
|
||||||
"referrerId" = $1
|
"referrerId" = $1
|
||||||
`, Number(me.id))
|
`, Number(me.id))
|
||||||
|
|
||||||
const stats = await models.$queryRaw(
|
const stats = await models.$queryRawUnsafe(
|
||||||
`${withClause(when)}
|
`${withClause(when)}
|
||||||
SELECT time, json_build_array(
|
SELECT time, json_build_array(
|
||||||
json_build_object('name', 'referrals', 'value', count(*) FILTER (WHERE act = 'REFERREE')),
|
json_build_object('name', 'referrals', 'value', count(*) FILTER (WHERE act = 'REFERREE')),
|
||||||
|
|
|
@ -42,7 +42,7 @@ export default {
|
||||||
await ssValidate(amountSchema, { amount: sats })
|
await ssValidate(amountSchema, { amount: sats })
|
||||||
|
|
||||||
await serialize(models,
|
await serialize(models,
|
||||||
models.$queryRaw(
|
models.$queryRawUnsafe(
|
||||||
'SELECT donate($1, $2)',
|
'SELECT donate($1, $2)',
|
||||||
sats, Number(me.id)))
|
sats, Number(me.id)))
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ async function serialize (models, call) {
|
||||||
return await retry(async bail => {
|
return await retry(async bail => {
|
||||||
try {
|
try {
|
||||||
const [, result] = await models.$transaction([
|
const [, result] = await models.$transaction([
|
||||||
models.$executeRaw(SERIALIZE),
|
models.$executeRawUnsafe(SERIALIZE),
|
||||||
call
|
call
|
||||||
])
|
])
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -119,7 +119,7 @@ export default {
|
||||||
},
|
},
|
||||||
topCowboys: async (parent, { cursor }, { models, me }) => {
|
topCowboys: async (parent, { cursor }, { models, me }) => {
|
||||||
const decodedCursor = decodeCursor(cursor)
|
const decodedCursor = decodeCursor(cursor)
|
||||||
const users = await models.$queryRaw(`
|
const users = await models.$queryRawUnsafe(`
|
||||||
SELECT users.*, floor(sum(msats_spent)/1000) as spent,
|
SELECT users.*, floor(sum(msats_spent)/1000) as spent,
|
||||||
sum(posts) as nposts, sum(comments) as ncomments, sum(referrals) as referrals,
|
sum(posts) as nposts, sum(comments) as ncomments, sum(referrals) as referrals,
|
||||||
floor(sum(msats_stacked)/1000) as stacked
|
floor(sum(msats_stacked)/1000) as stacked
|
||||||
|
@ -149,7 +149,7 @@ export default {
|
||||||
default: column = 'stacked'; break
|
default: column = 'stacked'; break
|
||||||
}
|
}
|
||||||
|
|
||||||
users = await models.$queryRaw(`
|
users = await models.$queryRawUnsafe(`
|
||||||
WITH u AS (
|
WITH u AS (
|
||||||
SELECT users.*, floor(sum(msats_spent)/1000) as spent,
|
SELECT users.*, floor(sum(msats_spent)/1000) as spent,
|
||||||
sum(posts) as nposts, sum(comments) as ncomments, sum(referrals) as referrals,
|
sum(posts) as nposts, sum(comments) as ncomments, sum(referrals) as referrals,
|
||||||
|
@ -172,7 +172,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (by === 'spent') {
|
if (by === 'spent') {
|
||||||
users = await models.$queryRaw(`
|
users = await models.$queryRawUnsafe(`
|
||||||
SELECT users.*, sum(sats_spent) as spent
|
SELECT users.*, sum(sats_spent) as spent
|
||||||
FROM
|
FROM
|
||||||
((SELECT "userId", floor(sum("ItemAct".msats)/1000) as sats_spent
|
((SELECT "userId", floor(sum("ItemAct".msats)/1000) as sats_spent
|
||||||
|
@ -192,7 +192,7 @@ export default {
|
||||||
OFFSET $2
|
OFFSET $2
|
||||||
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
|
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
|
||||||
} else if (by === 'posts') {
|
} else if (by === 'posts') {
|
||||||
users = await models.$queryRaw(`
|
users = await models.$queryRawUnsafe(`
|
||||||
SELECT users.*, count(*) as nposts
|
SELECT users.*, count(*) as nposts
|
||||||
FROM users
|
FROM users
|
||||||
JOIN "Item" on "Item"."userId" = users.id
|
JOIN "Item" on "Item"."userId" = users.id
|
||||||
|
@ -204,7 +204,7 @@ export default {
|
||||||
OFFSET $2
|
OFFSET $2
|
||||||
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
|
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
|
||||||
} else if (by === 'comments') {
|
} else if (by === 'comments') {
|
||||||
users = await models.$queryRaw(`
|
users = await models.$queryRawUnsafe(`
|
||||||
SELECT users.*, count(*) as ncomments
|
SELECT users.*, count(*) as ncomments
|
||||||
FROM users
|
FROM users
|
||||||
JOIN "Item" on "Item"."userId" = users.id
|
JOIN "Item" on "Item"."userId" = users.id
|
||||||
|
@ -216,7 +216,7 @@ export default {
|
||||||
OFFSET $2
|
OFFSET $2
|
||||||
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
|
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
|
||||||
} else if (by === 'referrals') {
|
} else if (by === 'referrals') {
|
||||||
users = await models.$queryRaw(`
|
users = await models.$queryRawUnsafe(`
|
||||||
SELECT users.*, count(*) as referrals
|
SELECT users.*, count(*) as referrals
|
||||||
FROM users
|
FROM users
|
||||||
JOIN "users" referree on users.id = referree."referrerId"
|
JOIN "users" referree on users.id = referree."referrerId"
|
||||||
|
@ -228,7 +228,7 @@ export default {
|
||||||
OFFSET $2
|
OFFSET $2
|
||||||
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
|
LIMIT ${LIMIT}`, decodedCursor.time, decodedCursor.offset)
|
||||||
} else {
|
} else {
|
||||||
users = await models.$queryRaw(`
|
users = await models.$queryRawUnsafe(`
|
||||||
SELECT u.id, u.name, u.streak, u."photoId", u."hideCowboyHat", floor(sum(amount)/1000) as stacked
|
SELECT u.id, u.name, u.streak, u."photoId", u."hideCowboyHat", floor(sum(amount)/1000) as stacked
|
||||||
FROM
|
FROM
|
||||||
((SELECT users.*, "ItemAct".msats as amount
|
((SELECT users.*, "ItemAct".msats as amount
|
||||||
|
@ -270,7 +270,7 @@ export default {
|
||||||
|
|
||||||
// check if any votes have been cast for them since checkedNotesAt
|
// check if any votes have been cast for them since checkedNotesAt
|
||||||
if (user.noteItemSats) {
|
if (user.noteItemSats) {
|
||||||
const votes = await models.$queryRaw(`
|
const votes = await models.$queryRawUnsafe(`
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM "Item"
|
FROM "Item"
|
||||||
JOIN "ItemAct" ON
|
JOIN "ItemAct" ON
|
||||||
|
@ -286,7 +286,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if they have any replies since checkedNotesAt
|
// check if they have any replies since checkedNotesAt
|
||||||
const newReplies = await models.$queryRaw(`
|
const newReplies = await models.$queryRawUnsafe(`
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM "Item"
|
FROM "Item"
|
||||||
JOIN "Item" p ON
|
JOIN "Item" p ON
|
||||||
|
@ -302,7 +302,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// break out thread subscription to decrease the search space of the already expensive reply query
|
// break out thread subscription to decrease the search space of the already expensive reply query
|
||||||
const newtsubs = await models.$queryRaw(`
|
const newtsubs = await models.$queryRawUnsafe(`
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM "ThreadSubscription"
|
FROM "ThreadSubscription"
|
||||||
JOIN "Item" p ON "ThreadSubscription"."itemId" = p.id
|
JOIN "Item" p ON "ThreadSubscription"."itemId" = p.id
|
||||||
|
@ -318,7 +318,7 @@ export default {
|
||||||
|
|
||||||
// check if they have any mentions since checkedNotesAt
|
// check if they have any mentions since checkedNotesAt
|
||||||
if (user.noteMentions) {
|
if (user.noteMentions) {
|
||||||
const newMentions = await models.$queryRaw(`
|
const newMentions = await models.$queryRawUnsafe(`
|
||||||
SELECT "Item".id, "Item".created_at
|
SELECT "Item".id, "Item".created_at
|
||||||
FROM "Mention"
|
FROM "Mention"
|
||||||
JOIN "Item" ON "Mention"."itemId" = "Item".id
|
JOIN "Item" ON "Mention"."itemId" = "Item".id
|
||||||
|
@ -379,7 +379,7 @@ export default {
|
||||||
|
|
||||||
// check if new invites have been redeemed
|
// check if new invites have been redeemed
|
||||||
if (user.noteInvites) {
|
if (user.noteInvites) {
|
||||||
const newInvitees = await models.$queryRaw(`
|
const newInvitees = await models.$queryRawUnsafe(`
|
||||||
SELECT "Invite".id
|
SELECT "Invite".id
|
||||||
FROM users JOIN "Invite" on users."inviteId" = "Invite".id
|
FROM users JOIN "Invite" on users."inviteId" = "Invite".id
|
||||||
WHERE "Invite"."userId" = $1
|
WHERE "Invite"."userId" = $1
|
||||||
|
@ -503,7 +503,7 @@ export default {
|
||||||
await updateItem(parent, { id: user.bioId, data: { text: bio, title: `@${user.name}'s bio` } }, { me, models })
|
await updateItem(parent, { id: user.bioId, data: { text: bio, title: `@${user.name}'s bio` } }, { me, models })
|
||||||
} else {
|
} else {
|
||||||
const [item] = await serialize(models,
|
const [item] = await serialize(models,
|
||||||
models.$queryRaw(`${SELECT} FROM create_bio($1, $2, $3) AS "Item"`,
|
models.$queryRawUnsafe(`${SELECT} FROM create_bio($1, $2, $3) AS "Item"`,
|
||||||
`@${user.name}'s bio`, bio, Number(me.id)))
|
`@${user.name}'s bio`, bio, Number(me.id)))
|
||||||
await createMentions(item, models)
|
await createMentions(item, models)
|
||||||
}
|
}
|
||||||
|
@ -645,7 +645,7 @@ export default {
|
||||||
// forever
|
// forever
|
||||||
return (user.stackedMsats && msatsToSats(user.stackedMsats)) || 0
|
return (user.stackedMsats && msatsToSats(user.stackedMsats)) || 0
|
||||||
} else if (when === 'day') {
|
} else if (when === 'day') {
|
||||||
const [{ stacked }] = await models.$queryRaw(`
|
const [{ stacked }] = await models.$queryRawUnsafe(`
|
||||||
SELECT sum(amount) as stacked
|
SELECT sum(amount) as stacked
|
||||||
FROM
|
FROM
|
||||||
((SELECT coalesce(sum("ItemAct".msats),0) as amount
|
((SELECT coalesce(sum("ItemAct".msats),0) as amount
|
||||||
|
@ -673,8 +673,8 @@ export default {
|
||||||
return user.spent
|
return user.spent
|
||||||
}
|
}
|
||||||
|
|
||||||
const { sum: { msats } } = await models.itemAct.aggregate({
|
const { _sum: { msats } } = await models.itemAct.aggregate({
|
||||||
sum: {
|
_sum: {
|
||||||
msats: true
|
msats: true
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
|
|
|
@ -145,7 +145,7 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let history = await models.$queryRaw(`
|
let history = await models.$queryRawUnsafe(`
|
||||||
${queries.join(' UNION ALL ')}
|
${queries.join(' UNION ALL ')}
|
||||||
ORDER BY "createdAt" DESC
|
ORDER BY "createdAt" DESC
|
||||||
OFFSET $3
|
OFFSET $3
|
||||||
|
@ -285,7 +285,7 @@ export default {
|
||||||
if (fact.type !== 'spent' && fact.type !== 'stacked') {
|
if (fact.type !== 'spent' && fact.type !== 'stacked') {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const [item] = await models.$queryRaw(`
|
const [item] = await models.$queryRawUnsafe(`
|
||||||
${SELECT}
|
${SELECT}
|
||||||
FROM "Item"
|
FROM "Item"
|
||||||
WHERE id = $1`, Number(fact.factId))
|
WHERE id = $1`, Number(fact.factId))
|
||||||
|
|
|
@ -33,7 +33,7 @@ const createUserFilter = (tag) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const createItemUrl = async ({ id }) => {
|
const createItemUrl = async ({ id }) => {
|
||||||
const [rootItem] = await models.$queryRaw(
|
const [rootItem] = await models.$queryRawUnsafe(
|
||||||
'SELECT subpath(path, -LEAST(nlevel(path), $1), 1)::text AS id FROM "Item" WHERE id = $2',
|
'SELECT subpath(path, -LEAST(nlevel(path), $1), 1)::text AS id FROM "Item" WHERE id = $2',
|
||||||
COMMENT_DEPTH_LIMIT + 1, Number(id)
|
COMMENT_DEPTH_LIMIT + 1, Number(id)
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"@graphql-tools/schema": "^10.0.0",
|
"@graphql-tools/schema": "^10.0.0",
|
||||||
"@noble/curves": "^1.1.0",
|
"@noble/curves": "^1.1.0",
|
||||||
"@opensearch-project/opensearch": "^2.3.1",
|
"@opensearch-project/opensearch": "^2.3.1",
|
||||||
"@prisma/client": "^2.30.3",
|
"@prisma/client": "^3.15.2",
|
||||||
"@synonymdev/slashtags-auth": "^1.0.0-alpha.5",
|
"@synonymdev/slashtags-auth": "^1.0.0-alpha.5",
|
||||||
"@synonymdev/slashtags-sdk": "^1.0.0-alpha.36",
|
"@synonymdev/slashtags-sdk": "^1.0.0-alpha.36",
|
||||||
"acorn": "^8.10.0",
|
"acorn": "^8.10.0",
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
"page-metadata-parser": "^1.1.4",
|
"page-metadata-parser": "^1.1.4",
|
||||||
"pageres": "^7.1.0",
|
"pageres": "^7.1.0",
|
||||||
"pg-boss": "^9.0.3",
|
"pg-boss": "^9.0.3",
|
||||||
"prisma": "^2.30.3",
|
"prisma": "^3.15.2",
|
||||||
"qrcode.react": "^3.1.0",
|
"qrcode.react": "^3.1.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-avatar-editor": "^13.0.0",
|
"react-avatar-editor": "^13.0.0",
|
||||||
|
@ -2982,15 +2982,15 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@prisma/client": {
|
"node_modules/@prisma/client": {
|
||||||
"version": "2.30.3",
|
"version": "3.15.2",
|
||||||
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-2.30.3.tgz",
|
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-3.15.2.tgz",
|
||||||
"integrity": "sha512-Ey2miZ+Hne12We3rA8XrlPoAF0iuKEhw5IK2nropaelSt0Ju3b2qSz9Qt50a/1Mx3+7yRSu/iSXt8y9TUMl/Yw==",
|
"integrity": "sha512-ErqtwhX12ubPhU4d++30uFY/rPcyvjk+mdifaZO5SeM21zS3t4jQrscy8+6IyB0GIYshl5ldTq6JSBo1d63i8w==",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@prisma/engines-version": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20"
|
"@prisma/engines-version": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12.2"
|
"node": ">=12.6"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"prisma": "*"
|
"prisma": "*"
|
||||||
|
@ -3002,15 +3002,15 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@prisma/engines": {
|
"node_modules/@prisma/engines": {
|
||||||
"version": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20",
|
"version": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e",
|
||||||
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20.tgz",
|
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e.tgz",
|
||||||
"integrity": "sha512-WPnA/IUrxDihrRhdP6+8KAVSwsc0zsh8ioPYsLJjOhzVhwpRbuFH2tJDRIAbc+qFh+BbTIZbeyBYt8fpNXaYQQ==",
|
"integrity": "sha512-NHlojO1DFTsSi3FtEleL9QWXeSF/UjhCW0fgpi7bumnNZ4wj/eQ+BJJ5n2pgoOliTOGv9nX2qXvmHap7rJMNmg==",
|
||||||
"hasInstallScript": true
|
"hasInstallScript": true
|
||||||
},
|
},
|
||||||
"node_modules/@prisma/engines-version": {
|
"node_modules/@prisma/engines-version": {
|
||||||
"version": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20",
|
"version": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e",
|
||||||
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20.tgz",
|
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e.tgz",
|
||||||
"integrity": "sha512-/iDRgaoSQC77WN2oDsOM8dn61fykm6tnZUAClY+6p+XJbOEgZ9gy4CKuKTBgrjSGDVjtQ/S2KGcYd3Ring8xaw=="
|
"integrity": "sha512-e3k2Vd606efd1ZYy2NQKkT4C/pn31nehyLhVug6To/q8JT8FpiMrDy7zmm3KLF0L98NOQQcutaVtAPhzKhzn9w=="
|
||||||
},
|
},
|
||||||
"node_modules/@protobufjs/aspromise": {
|
"node_modules/@protobufjs/aspromise": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
|
@ -15025,19 +15025,19 @@
|
||||||
"integrity": "sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew=="
|
"integrity": "sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew=="
|
||||||
},
|
},
|
||||||
"node_modules/prisma": {
|
"node_modules/prisma": {
|
||||||
"version": "2.30.3",
|
"version": "3.15.2",
|
||||||
"resolved": "https://registry.npmjs.org/prisma/-/prisma-2.30.3.tgz",
|
"resolved": "https://registry.npmjs.org/prisma/-/prisma-3.15.2.tgz",
|
||||||
"integrity": "sha512-48qYba2BIyUmXuosBZs0g3kYGrxKvo4VkSHYOuLlDdDirmKyvoY2hCYMUYHSx3f++8ovfgs+MX5KmNlP+iAZrQ==",
|
"integrity": "sha512-nMNSMZvtwrvoEQ/mui8L/aiCLZRCj5t6L3yujKpcDhIPk7garp8tL4nMx2+oYsN0FWBacevJhazfXAbV1kfBzA==",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@prisma/engines": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20"
|
"@prisma/engines": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"prisma": "build/index.js",
|
"prisma": "build/index.js",
|
||||||
"prisma2": "build/index.js"
|
"prisma2": "build/index.js"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12.2"
|
"node": ">=12.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/prismjs": {
|
"node_modules/prismjs": {
|
||||||
|
@ -22131,22 +22131,22 @@
|
||||||
"integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A=="
|
"integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A=="
|
||||||
},
|
},
|
||||||
"@prisma/client": {
|
"@prisma/client": {
|
||||||
"version": "2.30.3",
|
"version": "3.15.2",
|
||||||
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-2.30.3.tgz",
|
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-3.15.2.tgz",
|
||||||
"integrity": "sha512-Ey2miZ+Hne12We3rA8XrlPoAF0iuKEhw5IK2nropaelSt0Ju3b2qSz9Qt50a/1Mx3+7yRSu/iSXt8y9TUMl/Yw==",
|
"integrity": "sha512-ErqtwhX12ubPhU4d++30uFY/rPcyvjk+mdifaZO5SeM21zS3t4jQrscy8+6IyB0GIYshl5ldTq6JSBo1d63i8w==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@prisma/engines-version": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20"
|
"@prisma/engines-version": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@prisma/engines": {
|
"@prisma/engines": {
|
||||||
"version": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20",
|
"version": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e",
|
||||||
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20.tgz",
|
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e.tgz",
|
||||||
"integrity": "sha512-WPnA/IUrxDihrRhdP6+8KAVSwsc0zsh8ioPYsLJjOhzVhwpRbuFH2tJDRIAbc+qFh+BbTIZbeyBYt8fpNXaYQQ=="
|
"integrity": "sha512-NHlojO1DFTsSi3FtEleL9QWXeSF/UjhCW0fgpi7bumnNZ4wj/eQ+BJJ5n2pgoOliTOGv9nX2qXvmHap7rJMNmg=="
|
||||||
},
|
},
|
||||||
"@prisma/engines-version": {
|
"@prisma/engines-version": {
|
||||||
"version": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20",
|
"version": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e",
|
||||||
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20.tgz",
|
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e.tgz",
|
||||||
"integrity": "sha512-/iDRgaoSQC77WN2oDsOM8dn61fykm6tnZUAClY+6p+XJbOEgZ9gy4CKuKTBgrjSGDVjtQ/S2KGcYd3Ring8xaw=="
|
"integrity": "sha512-e3k2Vd606efd1ZYy2NQKkT4C/pn31nehyLhVug6To/q8JT8FpiMrDy7zmm3KLF0L98NOQQcutaVtAPhzKhzn9w=="
|
||||||
},
|
},
|
||||||
"@protobufjs/aspromise": {
|
"@protobufjs/aspromise": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
|
@ -30717,11 +30717,11 @@
|
||||||
"integrity": "sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew=="
|
"integrity": "sha512-WuxUnVtlWL1OfZFQFuqvnvs6MiAGk9UNsBostyBOB0Is9wb5uRESevA6rnl/rkksXaGX3GzZhPup5d6Vp1nFew=="
|
||||||
},
|
},
|
||||||
"prisma": {
|
"prisma": {
|
||||||
"version": "2.30.3",
|
"version": "3.15.2",
|
||||||
"resolved": "https://registry.npmjs.org/prisma/-/prisma-2.30.3.tgz",
|
"resolved": "https://registry.npmjs.org/prisma/-/prisma-3.15.2.tgz",
|
||||||
"integrity": "sha512-48qYba2BIyUmXuosBZs0g3kYGrxKvo4VkSHYOuLlDdDirmKyvoY2hCYMUYHSx3f++8ovfgs+MX5KmNlP+iAZrQ==",
|
"integrity": "sha512-nMNSMZvtwrvoEQ/mui8L/aiCLZRCj5t6L3yujKpcDhIPk7garp8tL4nMx2+oYsN0FWBacevJhazfXAbV1kfBzA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@prisma/engines": "2.30.1-2.b8c35d44de987a9691890b3ddf3e2e7effb9bf20"
|
"@prisma/engines": "3.15.1-1.461d6a05159055555eb7dfb337c9fb271cbd4d7e"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"prismjs": {
|
"prismjs": {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
"@graphql-tools/schema": "^10.0.0",
|
"@graphql-tools/schema": "^10.0.0",
|
||||||
"@noble/curves": "^1.1.0",
|
"@noble/curves": "^1.1.0",
|
||||||
"@opensearch-project/opensearch": "^2.3.1",
|
"@opensearch-project/opensearch": "^2.3.1",
|
||||||
"@prisma/client": "^2.30.3",
|
"@prisma/client": "^3.15.2",
|
||||||
"@synonymdev/slashtags-auth": "^1.0.0-alpha.5",
|
"@synonymdev/slashtags-auth": "^1.0.0-alpha.5",
|
||||||
"@synonymdev/slashtags-sdk": "^1.0.0-alpha.36",
|
"@synonymdev/slashtags-sdk": "^1.0.0-alpha.36",
|
||||||
"acorn": "^8.10.0",
|
"acorn": "^8.10.0",
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
"page-metadata-parser": "^1.1.4",
|
"page-metadata-parser": "^1.1.4",
|
||||||
"pageres": "^7.1.0",
|
"pageres": "^7.1.0",
|
||||||
"pg-boss": "^9.0.3",
|
"pg-boss": "^9.0.3",
|
||||||
"prisma": "^2.30.3",
|
"prisma": "^3.15.2",
|
||||||
"qrcode.react": "^3.1.0",
|
"qrcode.react": "^3.1.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-avatar-editor": "^13.0.0",
|
"react-avatar-editor": "^13.0.0",
|
||||||
|
|
|
@ -5,7 +5,7 @@ export default async (_, res) => {
|
||||||
// this should probably be made more generic
|
// this should probably be made more generic
|
||||||
// eg if the title changes this will break
|
// eg if the title changes this will break
|
||||||
// ... but this will need to change when we have more subs anyway
|
// ... but this will need to change when we have more subs anyway
|
||||||
const [{ id }] = await models.$queryRaw(`
|
const [{ id }] = await models.$queryRawUnsafe(`
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM "Item"
|
FROM "Item"
|
||||||
WHERE "pinId" IS NOT NULL
|
WHERE "pinId" IS NOT NULL
|
||||||
|
|
|
@ -33,7 +33,7 @@ export async function getServerSideProps ({ req, res, query: { id, error = null
|
||||||
// attempt to send gift
|
// attempt to send gift
|
||||||
// catch any errors and just ignore them for now
|
// catch any errors and just ignore them for now
|
||||||
await serialize(models,
|
await serialize(models,
|
||||||
models.$queryRaw('SELECT invite_drain($1, $2)', session.user.id, id))
|
models.$queryRawUnsafe('SELECT invite_drain($1, $2)', session.user.id, id))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -42,7 +42,7 @@ function earn ({ models }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get earners { userId, id, type, rank, proportion }
|
// get earners { userId, id, type, rank, proportion }
|
||||||
const earners = await models.$queryRaw(`
|
const earners = await models.$queryRawUnsafe(`
|
||||||
WITH item_ratios AS (
|
WITH item_ratios AS (
|
||||||
SELECT *,
|
SELECT *,
|
||||||
CASE WHEN "parentId" IS NULL THEN 'POST' ELSE 'COMMENT' END as type,
|
CASE WHEN "parentId" IS NULL THEN 'POST' ELSE 'COMMENT' END as type,
|
||||||
|
|
|
@ -7,7 +7,7 @@ function computeStreaks ({ models }) {
|
||||||
// get all eligible users in the last day
|
// get all eligible users in the last day
|
||||||
// if the user doesn't have an active streak, add one
|
// if the user doesn't have an active streak, add one
|
||||||
// if they have an active streak but didn't maintain it, end it
|
// if they have an active streak but didn't maintain it, end it
|
||||||
await models.$executeRaw(
|
await models.$executeRawUnsafe(
|
||||||
`WITH day_streaks (id) AS (
|
`WITH day_streaks (id) AS (
|
||||||
SELECT "userId"
|
SELECT "userId"
|
||||||
FROM
|
FROM
|
||||||
|
|
|
@ -165,7 +165,7 @@ async function storeTrust (models, nodeTrust) {
|
||||||
// update the trust of each user in graph
|
// update the trust of each user in graph
|
||||||
await models.$transaction([
|
await models.$transaction([
|
||||||
models.$executeRaw`UPDATE users SET trust = 0`,
|
models.$executeRaw`UPDATE users SET trust = 0`,
|
||||||
models.$executeRaw(
|
models.$executeRawUnsafe(
|
||||||
`UPDATE users
|
`UPDATE users
|
||||||
SET trust = g.trust
|
SET trust = g.trust
|
||||||
FROM (values ${values}) g(id, trust)
|
FROM (values ${values}) g(id, trust)
|
||||||
|
|
|
@ -6,7 +6,7 @@ function views ({ models }) {
|
||||||
for (const view of ['reg_growth_days', 'spender_growth_days', 'item_growth_days',
|
for (const view of ['reg_growth_days', 'spender_growth_days', 'item_growth_days',
|
||||||
'spending_growth_days', 'stackers_growth_days', 'stacking_growth_days',
|
'spending_growth_days', 'stackers_growth_days', 'stacking_growth_days',
|
||||||
'user_stats_days']) {
|
'user_stats_days']) {
|
||||||
await models.$queryRaw(`REFRESH MATERIALIZED VIEW CONCURRENTLY ${view}`)
|
await models.$queryRawUnsafe(`REFRESH MATERIALIZED VIEW CONCURRENTLY ${view}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('done refreshing stats views')
|
console.log('done refreshing stats views')
|
||||||
|
@ -19,7 +19,7 @@ function rankViews ({ models }) {
|
||||||
console.log('refreshing rank views')
|
console.log('refreshing rank views')
|
||||||
|
|
||||||
for (const view of ['sat_rank_wwm_view', 'sat_rank_tender_view']) {
|
for (const view of ['sat_rank_wwm_view', 'sat_rank_tender_view']) {
|
||||||
await models.$queryRaw(`REFRESH MATERIALIZED VIEW CONCURRENTLY ${view}`)
|
await models.$queryRawUnsafe(`REFRESH MATERIALIZED VIEW CONCURRENTLY ${view}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('done refreshing rank views')
|
console.log('done refreshing rank views')
|
||||||
|
|
Loading…
Reference in New Issue