Skip to content
Snippets Groups Projects

[Prove of concept] For sending feedback to report filing users, refactoring of the GQL schema, resolver

Closed Hannes Heine requested to merge pr3023head into pr3023base
3 files
+ 42
12
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -48,18 +48,41 @@ export default {
const readTxResultPromise = session.readTransaction(async transaction => {
const notificationsTransactionResponse = await transaction.run(
`
MATCH (resource)-[notification:NOTIFIED]->(user:User {id:$id})
WHERE
((labels(resource)[0] in ["Post", "Comment"] AND NOT resource.deleted AND NOT resource.disabled)
OR labels(resource)[0] in ["Report"])
// Wolle MATCH (resource)-[notification:NOTIFIED]->(user:User {id:$id})
// WHERE
// ((labels(resource)[0] in ["Post", "Comment"] AND NOT resource.deleted AND NOT resource.disabled)
// OR labels(resource)[0] in ["Report"])
// ${whereClause}
// WITH user, notification, resource,
// [(resource)<-[:WROTE]-(author:User) | author {.*}] AS authors,
// [(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post {.*, author: properties(author)} ] AS posts,
// [(reportedResource)<-[:BELONGS_TO]-(resource)<-[file:FILED]-(user) | file {.*, reportedResource: apoc.map.merge(properties(reportedResource), {__typename: labels(reportedResource)[0]})} ] AS files
// WITH resource, user, notification, authors, posts, files,
// resource {.*, __typename: labels(resource)[0], author: authors[0], post: posts[0], filed: files, resource: files[0].reportedResource} AS finalResource
// RETURN notification {.*, from: finalResource, to: properties(user)}
MATCH (author:User)-[:WROTE]->(post:Post)-[notification:NOTIFIED]->(user:User {id: $id})
WHERE NOT post.deleted AND NOT post.disabled
${whereClause}
WITH user, notification, post {.*, __typename: labels(post)[0], author: properties(author)}
RETURN notification {.*, from: post, to: properties(user)}
UNION ALL
MATCH (author:User)-[:WROTE]->(comment:Comment)-[:COMMENTS]->(post:Post)<-[:WROTE]-(postAuthor:User),
(comment)-[notification:NOTIFIED]->(user:User {id: $id})
WHERE NOT comment.deleted AND NOT comment.disabled
${whereClause}
WITH user, notification, comment {.*, __typename: labels(comment)[0], author: properties(author), post: apoc.map.merge(properties(post), {__typename: labels(post)[0], author: properties(postAuthor)})}
RETURN notification {.*, from: comment, to: properties(user)}
UNION ALL
MATCH (report:Report)-[notification:NOTIFIED]->(user:User {id:$id}),
(reportedResource)<-[:BELONGS_TO]-(report)<-[file:FILED]-(user)
WHERE (reportedResource:User) OR (reportedResource:Post) OR (reportedResource:Comment)
${whereClause}
WITH user, notification, resource,
[(resource)<-[:WROTE]-(author:User) | author {.*}] AS authors,
[(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post {.*, author: properties(author)} ] AS posts,
[(reportedResource)<-[:BELONGS_TO]-(resource)<-[file:FILED]-(user) | file {.*, reportedResource: apoc.map.merge(properties(reportedResource), {__typename: labels(reportedResource)[0]})} ] AS files
WITH resource, user, notification, authors, posts, files,
resource {.*, __typename: labels(resource)[0], author: authors[0], post: posts[0], filed: files, resource: files[0].reportedResource} AS finalResource
RETURN notification {.*, from: finalResource, to: properties(user)}
// Wolle - Here the three different case are not distinguished and therefore Post is not added to Comment and the authors are not added etc.
WITH user, notification, filedExpose {__typename: "FILEDExpose", reasonCategory: file.reasonCategory, reasonDescription: file.reasonDescription, reportedResource: apoc.map.merge(properties(reportedResource), {__typename: labels(reportedResource)[0]})}
RETURN notification {.*, from: filedExpose, to: properties(user)}
${orderByClause}
${offset} ${limit}
`,
Loading