Refactor report mutation

This commit is contained in:
Wolfgang Huß 2019-11-15 10:49:55 +01:00
parent bcd60c364d
commit d2442b73c9
2 changed files with 10 additions and 4 deletions

View File

@ -13,6 +13,12 @@ export default {
MATCH (submitter:User {id: $submitterId})
MATCH (resource {id: $resourceId})
WHERE resource:User OR resource:Comment OR resource:Post
//CREATE (resource)<-[report:REPORTED {createdAt: $createdAt, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription, closed: false}]-(submitter)
MATCH (resource)<-[:FLAGGED]-(case:Case {closed: false})
MERGE (resource)<-[:FLAGGED]-(case:Case {closed: false})
ON CREATE SET case.id = randomUUID(), case.updatedAt = toString(datetime()), case.createdAt = case.updatedAt, case.disable = true, case.closed = false
//WITH submitter, resource
CREATE (case)<-[report:REPORTED {createdAt: $createdAt, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription}]-(submitter)
CREATE (resource)<-[report:REPORTED {createdAt: $createdAt, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription, closed: false}]-(submitter)
RETURN report, submitter, resource, labels(resource)[0] as type
`,

View File

@ -29,10 +29,10 @@ WITH moderator, disabledResource, case
//, review
//OPTIONAL MATCH (noReporterDisabledResource:User)-[:REPORTED]->(disabledResource)
//WHERE noReporterDisabledResource IS NULL
OPTIONAL MATCH (:User)-[notExistingReport:REPORTED]->(disabledResource)
WHERE notExistingReport IS NULL
//MATCH (noReporterDisabledResource:User)
//WHERE NOT (noReporterDisabledResource:User)-[:REPORTED]->(disabledResource)
//OPTIONAL MATCH (:User)-[notExistingReport:REPORTED]->(disabledResource)
//WHERE notExistingReport IS NULL
OPTIONAL MATCH (noReporterDisabledResource:User)-[notExistingReport:REPORTED]->(disabledResource)
WHERE NOT (noReporterDisabledResource)-[notExistingReport]->(disabledResource)
CREATE (moderator)-[addModeratorReport:REPORTED]->(case)
SET addModeratorReport.createdAt = toString(datetime()), addModeratorReport.reasonCategory = 'other', addModeratorReport.reasonDescription = 'Old DISABLED relation had no now mandatory report !!! Created automatically to ensure database consistency! Creation date is when the database manipulation happened.'