mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Refactor script for db change
This commit is contained in:
parent
913fcc2cdb
commit
bcd60c364d
@ -16,12 +16,43 @@ do
|
||||
done
|
||||
|
||||
echo "
|
||||
MATCH (moderator:User)-[disabled:DISABLED]->(resource)
|
||||
// convert old DISABLED to new REVIEWED-Case-FLAGGED structure
|
||||
MATCH (moderator:User)-[disabled:DISABLED]->(disabledResource)
|
||||
WHERE disabledResource:User OR disabledResource:Comment OR disabledResource:Post
|
||||
DELETE disabled
|
||||
CREATE (moderator)-[decision:DECIDED]->(resource)
|
||||
SET decision.updatedAt = toString(datetime()), decision.createdAt = decision.updatedAt, decision.disable = true, decision.latest = true, decision.closed = false
|
||||
WITH decision
|
||||
MATCH (:User)-[report:REPORTED]->(resource)
|
||||
SET report.closed = false
|
||||
RETURN decision, report;
|
||||
CREATE (moderator)-[review:REVIEWED]->(case:Case)-[:FLAGGED]->(disabledResource)
|
||||
SET review.updatedAt = toString(datetime()), review.createdAt = review.updatedAt, review.disable = true
|
||||
SET case.id = randomUUID(), case.updatedAt = toString(datetime()), case.createdAt = case.updatedAt, case.disable = true, case.closed = false
|
||||
|
||||
// if disabledResource has no report, then create a moderators default report
|
||||
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)
|
||||
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.'
|
||||
|
||||
// if disabledResource has reports, then convert them
|
||||
WITH disabledResource, case
|
||||
//, review
|
||||
MATCH (reporterDisabledResource:User)-[existingReport:REPORTED]->(disabledResource)
|
||||
DELETE existingReport
|
||||
CREATE (reporterDisabledResource)-[reportDisabledResource:REPORTED]->(case)
|
||||
SET reportDisabledResource = existingReport
|
||||
|
||||
// for REPORTED resources without DISABLED relation which are handled above, create new REPORTED-Case-FLAGGED structure
|
||||
WITH
|
||||
MATCH (reporter:User)-[oldReport:REPORTED]->(noDisabledResource)
|
||||
WHERE noDisabledResource:User OR noDisabledResource:Comment OR noDisabledResource:Post
|
||||
DELETE oldReport
|
||||
CREATE (reporter)-[report:REPORTED]->(case:Case)
|
||||
MERGE (case)-[:FLAGGED]->(noDisabledResource)
|
||||
SET report = oldReport
|
||||
SET case.id = randomUUID(), case.updatedAt = toString(datetime()), case.createdAt = case.updatedAt, case.disable = false, case.closed = false
|
||||
|
||||
RETURN disabledResource, noDisabledResource, review, report, addModeratorReport;
|
||||
" | cypher-shell
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user