mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Eliminate database calls for filed and reviewed
I learned map projections and list comprehensions in cypher tonight!
🎉 So much wow!
This commit is contained in:
parent
942e74163e
commit
2f2bf571ed
@ -66,14 +66,17 @@ export default {
|
||||
const reportReadTxPromise = session.readTransaction(async tx => {
|
||||
const allReportsTransactionResponse = await tx.run(
|
||||
`
|
||||
MATCH (submitter:User)-[filed:FILED]->(report:Report)-[:BELONGS_TO]->(resource)
|
||||
MATCH (report:Report)-[:BELONGS_TO]->(resource)
|
||||
WHERE resource:User OR resource:Post OR resource:Comment
|
||||
RETURN DISTINCT report, resource, labels(resource)[0] as type
|
||||
WITH report, resource,
|
||||
[(submitter:User)-[filed:FILED]->(report) | filed {.*, submitter: properties(submitter)} ] as filed,
|
||||
[(moderator:User)-[reviewed:REVIEWED]->(report) | reviewed {.*, moderator: properties(moderator)} ] as reviewed,
|
||||
resource {.*, __typename: labels(resource)[0] } as resourceWithType
|
||||
RETURN report {.*, resource: resourceWithType, filed: filed, reviewed: reviewed}
|
||||
${orderByClause}
|
||||
`,
|
||||
{},
|
||||
)
|
||||
return allReportsTransactionResponse.records.map(transformReturnType)
|
||||
return allReportsTransactionResponse.records.map(record => record.get('report'))
|
||||
})
|
||||
try {
|
||||
const txResult = await reportReadTxPromise
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user