store last time user visited so we can guage retention
This commit is contained in:
parent
344958943c
commit
46f552b803
|
@ -27,8 +27,15 @@ export function topClause (within) {
|
|||
|
||||
export default {
|
||||
Query: {
|
||||
me: async (parent, args, { models, me }) =>
|
||||
me ? await models.user.findUnique({ where: { id: me.id } }) : null,
|
||||
me: async (parent, args, { models, me }) => {
|
||||
if (!me) {
|
||||
return null
|
||||
}
|
||||
|
||||
await models.user.update({ where: { id: me.id }, data: { lastSeenAt: new Date() } })
|
||||
|
||||
return await models.user.findUnique({ where: { id: me.id } })
|
||||
},
|
||||
user: async (parent, { name }, { models }) => {
|
||||
return await models.user.findUnique({ where: { name } })
|
||||
},
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "lastSeenAt" TIMESTAMP(3);
|
|
@ -36,6 +36,7 @@ model User {
|
|||
tipDefault Int @default(1)
|
||||
pubkey String? @unique
|
||||
trust Float @default(0)
|
||||
lastSeenAt DateTime?
|
||||
|
||||
upvotePopover Boolean @default(false)
|
||||
tipPopover Boolean @default(false)
|
||||
|
|
Loading…
Reference in New Issue