mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Set notifications.createdAt only at creation
- we should not be setting it every time a notification is created
This commit is contained in:
parent
2a3e6ad76f
commit
ce487f1e0f
@ -27,7 +27,10 @@ const notifyUsers = async (label, id, idsOfUsers, reason, context) => {
|
||||
MERGE (post)-[notification:NOTIFIED {reason: $reason}]->(user)
|
||||
SET notification.read = FALSE
|
||||
SET notification.updatedAt = toString(datetime())
|
||||
SET notification.createdAt = toString(datetime())
|
||||
SET (
|
||||
CASE
|
||||
WHEN notification.createdAt IS NULL
|
||||
THEN notification END ).createdAt = toString(datetime())
|
||||
`
|
||||
break
|
||||
}
|
||||
@ -41,7 +44,10 @@ const notifyUsers = async (label, id, idsOfUsers, reason, context) => {
|
||||
MERGE (comment)-[notification:NOTIFIED {reason: $reason}]->(user)
|
||||
SET notification.read = FALSE
|
||||
SET notification.updatedAt = toString(datetime())
|
||||
SET notification.createdAt = toString(datetime())
|
||||
SET (
|
||||
CASE
|
||||
WHEN notification.createdAt IS NULL
|
||||
THEN notification END ).createdAt = toString(datetime())
|
||||
`
|
||||
break
|
||||
}
|
||||
@ -55,7 +61,10 @@ const notifyUsers = async (label, id, idsOfUsers, reason, context) => {
|
||||
MERGE (comment)-[notification:NOTIFIED {reason: $reason}]->(user)
|
||||
SET notification.read = FALSE
|
||||
SET notification.updatedAt = toString(datetime())
|
||||
SET notification.createdAt = toString(datetime())
|
||||
SET (
|
||||
CASE
|
||||
WHEN notification.createdAt IS NULL
|
||||
THEN notification END ).createdAt = toString(datetime())
|
||||
`
|
||||
break
|
||||
}
|
||||
|
||||
@ -391,7 +391,7 @@ describe('notifications', () => {
|
||||
expect(Date.parse(createdAtBefore)).toEqual(expect.any(Number))
|
||||
expect(createdAtAfter).toBeTruthy()
|
||||
expect(Date.parse(createdAtAfter)).toEqual(expect.any(Number))
|
||||
expect(createdAtBefore).not.toEqual(createdAtAfter)
|
||||
expect(createdAtBefore).toEqual(createdAtAfter)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -21,7 +21,7 @@ export default {
|
||||
SET comment.createdAt = toString(datetime())
|
||||
SET comment.updatedAt = toString(datetime())
|
||||
MERGE (post)<-[:COMMENTS]-(comment)<-[:WROTE]-(author)
|
||||
RETURN comment, author
|
||||
RETURN comment
|
||||
`
|
||||
const transactionRes = await session.run(createCommentCypher, {
|
||||
userId: context.user.id,
|
||||
@ -30,12 +30,7 @@ export default {
|
||||
})
|
||||
session.close()
|
||||
|
||||
const [response] = transactionRes.records.map(record => {
|
||||
return {
|
||||
...record.get('comment').properties,
|
||||
author: record.get('author').properties,
|
||||
}
|
||||
})
|
||||
const [response] = transactionRes.records.map(record => record.get('comment').properties)
|
||||
|
||||
return response
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user