case insensitive names
This commit is contained in:
parent
bf6b2befde
commit
38ba31f2b4
|
@ -44,38 +44,38 @@ export default {
|
||||||
|
|
||||||
let notifications = await models.$queryRaw(`
|
let notifications = await models.$queryRaw(`
|
||||||
SELECT ${ITEM_FIELDS}, "Item".created_at as "sortTime", NULL as "earnedSats",
|
SELECT ${ITEM_FIELDS}, "Item".created_at as "sortTime", NULL as "earnedSats",
|
||||||
false as mention
|
false as mention
|
||||||
From "Item"
|
FROM "Item"
|
||||||
JOIN "Item" p ON "Item"."parentId" = p.id
|
JOIN "Item" p ON "Item"."parentId" = p.id
|
||||||
WHERE p."userId" = $1
|
WHERE p."userId" = $1
|
||||||
AND "Item"."userId" <> $1 AND "Item".created_at <= $2
|
AND "Item"."userId" <> $1 AND "Item".created_at <= $2
|
||||||
UNION ALL
|
UNION ALL
|
||||||
(SELECT ${ITEM_SUBQUERY_FIELDS}, max(subquery.voted_at) as "sortTime",
|
(SELECT ${ITEM_SUBQUERY_FIELDS}, max(subquery.voted_at) as "sortTime",
|
||||||
sum(subquery.sats) as "earnedSats", false as mention
|
sum(subquery.sats) as "earnedSats", false as mention
|
||||||
FROM
|
FROM
|
||||||
(SELECT ${ITEM_FIELDS}, "Vote".created_at as voted_at, "Vote".sats,
|
(SELECT ${ITEM_FIELDS}, "Vote".created_at as voted_at, "Vote".sats,
|
||||||
ROW_NUMBER() OVER(ORDER BY "Vote".created_at) -
|
ROW_NUMBER() OVER(ORDER BY "Vote".created_at) -
|
||||||
ROW_NUMBER() OVER(PARTITION BY "Item".id ORDER BY "Vote".created_at) as island
|
ROW_NUMBER() OVER(PARTITION BY "Item".id ORDER BY "Vote".created_at) as island
|
||||||
FROM "Vote"
|
FROM "Vote"
|
||||||
JOIN "Item" on "Vote"."itemId" = "Item".id
|
JOIN "Item" on "Vote"."itemId" = "Item".id
|
||||||
WHERE "Vote"."userId" <> $1
|
WHERE "Vote"."userId" <> $1
|
||||||
AND "Vote".created_at <= $2
|
AND "Vote".created_at <= $2
|
||||||
AND "Vote".boost = false
|
AND "Vote".boost = false
|
||||||
AND "Item"."userId" = $1) subquery
|
AND "Item"."userId" = $1) subquery
|
||||||
GROUP BY ${ITEM_SUBQUERY_FIELDS}, subquery.island ORDER BY max(subquery.voted_at) desc)
|
GROUP BY ${ITEM_SUBQUERY_FIELDS}, subquery.island ORDER BY max(subquery.voted_at) desc)
|
||||||
UNION ALL
|
UNION ALL
|
||||||
(SELECT ${ITEM_FIELDS}, "Mention".created_at as "sortTime", NULL as "earnedSats",
|
(SELECT ${ITEM_FIELDS}, "Mention".created_at as "sortTime", NULL as "earnedSats",
|
||||||
true as mention
|
true as mention
|
||||||
FROM "Mention"
|
FROM "Mention"
|
||||||
JOIN "Item" on "Mention"."itemId" = "Item".id
|
JOIN "Item" on "Mention"."itemId" = "Item".id
|
||||||
JOIN "Item" p on "Item"."parentId" = p.id
|
JOIN "Item" p on "Item"."parentId" = p.id
|
||||||
WHERE "Mention"."userId" = $1
|
WHERE "Mention"."userId" = $1
|
||||||
AND "Mention".created_at <= $2
|
AND "Mention".created_at <= $2
|
||||||
AND "Item"."userId" <> $1
|
AND "Item"."userId" <> $1
|
||||||
AND p."userId" <> $1)
|
AND p."userId" <> $1)
|
||||||
ORDER BY "sortTime" DESC
|
ORDER BY "sortTime" DESC
|
||||||
OFFSET $3
|
OFFSET $3
|
||||||
LIMIT ${LIMIT}`, me.id, decodedCursor.time, decodedCursor.offset)
|
LIMIT ${LIMIT}`, me.id, decodedCursor.time, decodedCursor.offset)
|
||||||
|
|
||||||
notifications = notifications.map(n => {
|
notifications = notifications.map(n => {
|
||||||
n.item = { ...n }
|
n.item = { ...n }
|
||||||
|
|
|
@ -14,7 +14,7 @@ export default {
|
||||||
throw new AuthenticationError('you must be logged in')
|
throw new AuthenticationError('you must be logged in')
|
||||||
}
|
}
|
||||||
|
|
||||||
return me.name === name || !(await models.user.findUnique({ where: { name } }))
|
return me.name?.toUpperCase() === name?.toUpperCase() || !(await models.user.findUnique({ where: { name } }))
|
||||||
},
|
},
|
||||||
recentlyStacked: async (parent, args, { models, me }) => {
|
recentlyStacked: async (parent, args, { models, me }) => {
|
||||||
if (!me) {
|
if (!me) {
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- A unique constraint covering the columns `[name]` on the table `users` will be added. If there are existing duplicate values, this will fail.
|
||||||
|
|
||||||
|
*/
|
||||||
|
CREATE EXTENSION IF NOT EXISTS citext;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE users ALTER COLUMN name TYPE citext;
|
|
@ -14,7 +14,7 @@ model User {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
createdAt DateTime @default(now()) @map(name: "created_at")
|
createdAt DateTime @default(now()) @map(name: "created_at")
|
||||||
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
|
updatedAt DateTime @default(now()) @updatedAt @map(name: "updated_at")
|
||||||
name String? @unique
|
name String? @unique @db.Citext
|
||||||
email String? @unique
|
email String? @unique
|
||||||
emailVerified DateTime? @map(name: "email_verified")
|
emailVerified DateTime? @map(name: "email_verified")
|
||||||
image String?
|
image String?
|
||||||
|
|
Loading…
Reference in New Issue