use list comprehension instead of filter(not supported anymore in 4.4)

This commit is contained in:
Ulf Gebhardt 2023-06-16 15:34:27 +02:00
parent eb6825b6e6
commit df139c9937
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
7 changed files with 15 additions and 15 deletions

View File

@ -238,7 +238,7 @@ const notifyUsersOfMention = async (label, id, idsOfUsers, reason, context) => {
[(resource)<-[:WROTE]-(author:User) | author {.*}] AS authors, [(resource)<-[:WROTE]-(author:User) | author {.*}] AS authors,
[(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post{.*, author: properties(author)} ] AS posts [(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post{.*, author: properties(author)} ] AS posts
WITH resource, user, notification, authors, posts, WITH resource, user, notification, authors, posts,
resource {.*, __typename: filter(l IN labels(resource) WHERE l IN ['Post', 'Comment', 'Group'])[0], author: authors[0], post: posts[0]} AS finalResource resource {.*, __typename: [l IN labels(resource) WHERE l IN ['Post', 'Comment', 'Group']][0], author: authors[0], post: posts[0]} AS finalResource
SET notification.read = FALSE SET notification.read = FALSE
SET notification.createdAt = COALESCE(notification.createdAt, toString(datetime())) SET notification.createdAt = COALESCE(notification.createdAt, toString(datetime()))
SET notification.updatedAt = toString(datetime()) SET notification.updatedAt = toString(datetime())

View File

@ -64,7 +64,7 @@ const validateReview = async (resolve, root, args, context, info) => {
WHERE resource:User OR resource:Post OR resource:Comment WHERE resource:User OR resource:Post OR resource:Comment
OPTIONAL MATCH (:User)-[filed:FILED]->(:Report {closed: false})-[:BELONGS_TO]->(resource) OPTIONAL MATCH (:User)-[filed:FILED]->(:Report {closed: false})-[:BELONGS_TO]->(resource)
OPTIONAL MATCH (resource)<-[:WROTE]-(author:User) OPTIONAL MATCH (resource)<-[:WROTE]-(author:User)
RETURN filter(l IN labels(resource) WHERE l IN ['Post', 'Comment', 'User'])[0] AS label, author, filed RETURN [l IN labels(resource) WHERE l IN ['Post', 'Comment', 'User']][0] AS label, author, filed
`, `,
{ {
resourceId, resourceId,

View File

@ -18,7 +18,7 @@ export default {
SET report.updatedAt = $dateTime, report.disable = review.disable, report.closed = $params.closed SET report.updatedAt = $dateTime, report.disable = review.disable, report.closed = $params.closed
SET resource.disabled = report.disable SET resource.disabled = report.disable
WITH review, report, resource {.*, __typename: filter(l IN labels(resource) WHERE l IN ['Post', 'Comment', 'User'])[0]} AS finalResource WITH review, report, resource {.*, __typename: [l IN labels(resource) WHERE l IN ['Post', 'Comment', 'User']][0]} AS finalResource
RETURN review {.*, report: properties(report), resource: properties(finalResource)} RETURN review {.*, report: properties(report), resource: properties(finalResource)}
` `
const reviewWriteTxResultPromise = session.writeTransaction(async (txc) => { const reviewWriteTxResultPromise = session.writeTransaction(async (txc) => {

View File

@ -51,10 +51,10 @@ export default {
OPTIONAL MATCH (resource)<-[membership:MEMBER_OF]-(relatedUser) OPTIONAL MATCH (resource)<-[membership:MEMBER_OF]-(relatedUser)
WITH user, notification, resource, membership, relatedUser, WITH user, notification, resource, membership, relatedUser,
[(resource)<-[:WROTE]-(author:User) | author {.*}] AS authors, [(resource)<-[:WROTE]-(author:User) | author {.*}] AS authors,
[(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post {.*, author: properties(author), postType: filter(l IN labels(post) WHERE NOT l = "Post")} ] AS posts [(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post {.*, author: properties(author), postType: [l IN labels(post) WHERE NOT l = "Post"]} ] AS posts
WITH resource, user, notification, authors, posts, relatedUser, membership, WITH resource, user, notification, authors, posts, relatedUser, membership,
resource {.*, resource {.*,
__typename: filter(l IN labels(resource) WHERE l IN ['Post', 'Comment', 'Group'])[0], __typename: [l IN labels(resource) WHERE l IN ['Post', 'Comment', 'Group']][0],
author: authors[0], author: authors[0],
post: posts[0], post: posts[0],
myRole: membership.role } AS finalResource myRole: membership.role } AS finalResource
@ -90,10 +90,10 @@ export default {
SET notification.read = TRUE SET notification.read = TRUE
WITH user, notification, resource, WITH user, notification, resource,
[(resource)<-[:WROTE]-(author:User) | author {.*}] AS authors, [(resource)<-[:WROTE]-(author:User) | author {.*}] AS authors,
[(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post{.*, author: properties(author), postType: filter(l IN labels(post) WHERE NOT l = "Post")} ] AS posts [(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post{.*, author: properties(author), postType: [l IN labels(post) WHERE NOT l = "Post"]} ] AS posts
OPTIONAL MATCH (resource)<-[membership:MEMBER_OF]-(user) OPTIONAL MATCH (resource)<-[membership:MEMBER_OF]-(user)
WITH resource, user, notification, authors, posts, membership, WITH resource, user, notification, authors, posts, membership,
resource {.*, __typename: filter(l IN labels(resource) WHERE l IN ['Post', 'Comment', 'Group'])[0], author: authors[0], post: posts[0], myRole: membership.role } AS finalResource resource {.*, __typename: [l IN labels(resource) WHERE l IN ['Post', 'Comment', 'Group']][0], author: authors[0], post: posts[0], myRole: membership.role } AS finalResource
RETURN notification {.*, from: finalResource, to: properties(user)} RETURN notification {.*, from: finalResource, to: properties(user)}
`, `,
{ resourceId: args.id, id: currentUser.id }, { resourceId: args.id, id: currentUser.id },
@ -120,10 +120,10 @@ export default {
SET notification.read = TRUE SET notification.read = TRUE
WITH user, notification, resource, WITH user, notification, resource,
[(resource)<-[:WROTE]-(author:User) | author {.*}] AS authors, [(resource)<-[:WROTE]-(author:User) | author {.*}] AS authors,
[(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post{.*, author: properties(author), postType: filter(l IN labels(post) WHERE NOT l = "Post")} ] AS posts [(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post{.*, author: properties(author), postType: [l IN labels(post) WHERE NOT l = "Post"]} ] AS posts
OPTIONAL MATCH (resource)<-[membership:MEMBER_OF]-(user) OPTIONAL MATCH (resource)<-[membership:MEMBER_OF]-(user)
WITH resource, user, notification, authors, posts, membership, WITH resource, user, notification, authors, posts, membership,
resource {.*, __typename: filter(l IN labels(resource) WHERE l IN ['Post', 'Comment', 'Group'])[0], author: authors[0], post: posts[0], myRole: membership.role} AS finalResource resource {.*, __typename: [l IN labels(resource) WHERE l IN ['Post', 'Comment', 'Group']][0], author: authors[0], post: posts[0], myRole: membership.role} AS finalResource
RETURN notification {.*, from: finalResource, to: properties(user)} RETURN notification {.*, from: finalResource, to: properties(user)}
`, `,
{ id: currentUser.id }, { id: currentUser.id },

View File

@ -146,7 +146,7 @@ export default {
MERGE (post)<-[:WROTE]-(author) MERGE (post)<-[:WROTE]-(author)
${categoriesCypher} ${categoriesCypher}
${groupCypher} ${groupCypher}
RETURN post {.*, postType: filter(l IN labels(post) WHERE NOT l = "Post") } RETURN post {.*, postType: [l IN labels(post) WHERE NOT l = "Post"] }
`, `,
{ userId: context.user.id, categoryIds, groupId, params }, { userId: context.user.id, categoryIds, groupId, params },
) )
@ -214,7 +214,7 @@ export default {
` `
} }
updatePostCypher += `RETURN post {.*, postType: filter(l IN labels(post) WHERE NOT l = "Post")}` updatePostCypher += `RETURN post {.*, postType: [l IN labels(post) WHERE NOT l = "Post"]}`
const updatePostVariables = { categoryIds, params } const updatePostVariables = { categoryIds, params }
try { try {
const writeTxResultPromise = session.writeTransaction(async (transaction) => { const writeTxResultPromise = session.writeTransaction(async (transaction) => {

View File

@ -17,7 +17,7 @@ export default {
WITH submitter, resource, report WITH submitter, resource, report
CREATE (report)<-[filed:FILED {createdAt: $createdAt, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription}]-(submitter) CREATE (report)<-[filed:FILED {createdAt: $createdAt, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription}]-(submitter)
WITH filed, report, resource {.*, __typename: filter(l IN labels(resource) WHERE l IN ['Post', 'Comment', 'User'])[0]} AS finalResource WITH filed, report, resource {.*, __typename: [l IN labels(resource) WHERE l IN ['Post', 'Comment', 'User']][0]} AS finalResource
RETURN filed {.*, reportId: report.id, resource: properties(finalResource)} AS filedReport RETURN filed {.*, reportId: report.id, resource: properties(finalResource)} AS filedReport
`, `,
{ {
@ -92,8 +92,8 @@ export default {
[(submitter:User)-[filed:FILED]->(report) | filed {.*, submitter: properties(submitter)} ] as filed, [(submitter:User)-[filed:FILED]->(report) | filed {.*, submitter: properties(submitter)} ] as filed,
[(moderator:User)-[reviewed:REVIEWED]->(report) | reviewed {.*, moderator: properties(moderator)} ] as reviewed, [(moderator:User)-[reviewed:REVIEWED]->(report) | reviewed {.*, moderator: properties(moderator)} ] as reviewed,
[(resource)<-[:WROTE]-(author:User) | author {.*} ] as optionalAuthors, [(resource)<-[:WROTE]-(author:User) | author {.*} ] as optionalAuthors,
[(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post {.*, author: properties(author), postType: filter(l IN labels(post) WHERE NOT l = "Post")} ] as optionalCommentedPosts, [(resource)-[:COMMENTS]->(post:Post)<-[:WROTE]-(author:User) | post {.*, author: properties(author), postType: [l IN labels(post) WHERE NOT l = "Post")] ] as optionalCommentedPosts,
resource {.*, __typename: filter(l IN labels(resource) WHERE l IN ['Post', 'Comment', 'User'])[0] } as resourceWithType resource {.*, __typename: [l IN labels(resource) WHERE l IN ['Post', 'Comment', 'User']][0] } as resourceWithType
WITH report, optionalAuthors, optionalCommentedPosts, reviewed, filed, WITH report, optionalAuthors, optionalCommentedPosts, reviewed, filed,
resourceWithType {.*, post: optionalCommentedPosts[0], author: optionalAuthors[0] } as finalResource resourceWithType {.*, post: optionalCommentedPosts[0], author: optionalAuthors[0] } as finalResource
RETURN report {.*, resource: finalResource, filed: filed, reviewed: reviewed } RETURN report {.*, resource: finalResource, filed: filed, reviewed: reviewed }

View File

@ -178,7 +178,7 @@ type Post {
group: Group @relation(name: "IN", direction: "OUT") group: Group @relation(name: "IN", direction: "OUT")
postType: [PostType] postType: [PostType]
@cypher(statement: "RETURN filter(l IN labels(this) WHERE NOT l = 'Post')") @cypher(statement: "RETURN [l IN labels(this) WHERE NOT l = 'Post']")
eventLocationName: String eventLocationName: String
eventLocation: Location @cypher(statement: "MATCH (this)-[:IS_IN]->(l:Location) RETURN l") eventLocation: Location @cypher(statement: "MATCH (this)-[:IS_IN]->(l:Location) RETURN l")