diff --git a/backend/src/schema/index.js b/backend/src/schema/index.js index d1ff7ada0..6f58ab131 100644 --- a/backend/src/schema/index.js +++ b/backend/src/schema/index.js @@ -20,7 +20,7 @@ export default makeAugmentedSchema({ 'NOTIFIED', 'REPORTED', 'REVIEWED', - 'CaseFolder', + 'Claim', 'Donations', ], }, diff --git a/backend/src/schema/resolvers/helpers/claimResource.js b/backend/src/schema/resolvers/helpers/claimResource.js index 22ec69f5f..55bc83079 100644 --- a/backend/src/schema/resolvers/helpers/claimResource.js +++ b/backend/src/schema/resolvers/helpers/claimResource.js @@ -2,10 +2,10 @@ export async function queryReviewedByModerator(label, parent, context) { if (typeof parent.reviewedByModerator !== 'undefined') return parent.reviewedByModerator const { id } = parent const statement = ` - MATCH (resource {id: $id})<-[:FLAGGED]-(caseFolder:CaseFolder)<-[review:REVIEWED]-(moderator:User) + MATCH (resource {id: $id})<-[:BELONGS_TO]-(claim:Claim)<-[review:REVIEWED]-(moderator:User) WHERE $label IN labels(resource) RETURN moderator - ORDER BY caseFolder.updatedAt DESC, review.updatedAt DESC + ORDER BY claim.updatedAt DESC, review.updatedAt DESC LIMIT 1 ` let reviewedByModerator diff --git a/backend/src/schema/resolvers/moderation.js b/backend/src/schema/resolvers/moderation.js index c61b7f5fe..594ca4b3c 100644 --- a/backend/src/schema/resolvers/moderation.js +++ b/backend/src/schema/resolvers/moderation.js @@ -10,14 +10,14 @@ // // Wolle only review on reported resources -// MATCH (caseModerator:User)-[:REPORTED]->(caseFolder:CaseFolder {closed: false})-[:FLAGGED]->(resource {id: $resourceId}) +// MATCH (caseModerator:User)-[:REPORTED]->(claim:Claim {closed: false})-[:BELONGS_TO]->(resource {id: $resourceId}) // WHERE resource:User OR resource:Post OR resource:Comment -// RETURN caseFolder, caseModerator {.id} +// RETURN claim, caseModerator {.id} // `, // { resourceId }, // ) // return queryOpenDecisionTransactionResponse.records.map(record => ({ -// caseFolder: record.get('caseFolder'), +// claim: record.get('claim'), // caseModerator: record.get('caseModerator'), // })) // }) @@ -54,7 +54,7 @@ export default { // // Wolle openDecisionTxResult should not be undefined !!! // if (!openDecisionTxResult) { - // // no open caseFolder, then create one + // // no open claim, then create one // if (disable === undefined) disable = false // default for creation // if (closed === undefined) closed = false // default for creation // cypherHeader = ` @@ -68,9 +68,9 @@ export default { // SET decision.latest = true // ` // } else { - // // an open caseFolder, then change it - // if (disable === undefined) disable = openDecisionTxResult.caseFolder.properties.disable // default set to existing - // if (closed === undefined) closed = openDecisionTxResult.caseFolder.properties.closed // default set to existing + // // an open claim, then change it + // if (disable === undefined) disable = openDecisionTxResult.claim.properties.disable // default set to existing + // if (closed === undefined) closed = openDecisionTxResult.claim.properties.closed // default set to existing // // current moderator is not the same as old // if (moderator.id !== openDecisionTxResult.caseModerator.id) { // // from a different moderator, then create relation with properties to new moderator @@ -85,7 +85,7 @@ export default { // SET decision = oldDecision // ` // } else { - // // an open caseFolder from same moderator, then match this + // // an open claim from same moderator, then match this // cypherHeader = ` // MATCH (moderator:User)-[decision:DECIDED {closed: false}]->(resource {id: $resourceId}) // WHERE resource:User OR resource:Comment OR resource:Post @@ -121,17 +121,17 @@ export default { MATCH (resource {id: $resourceId}) WHERE resource:User OR resource:Post OR resource:Comment // report exists? - //WHERE (caseFolder)<-[report:REPORTED]-(submitter:User) + //WHERE (claim)<-[report:REPORTED]-(submitter:User) - // no open caseFolder, create one, update existing - MERGE (resource)<-[:FLAGGED]-(caseFolder:CaseFolder {closed: false}) - ON CREATE SET caseFolder.id = randomUUID(), caseFolder.createdAt = $dateTime, caseFolder.updatedAt = caseFolder.createdAt, caseFolder.rule = 'latestReviewUpdatedAtRules', caseFolder.disable = false, caseFolder.closed = false - ON MATCH SET caseFolder.updatedAt = $dateTime - // caseFolder.disable and caseFolder.closed are set after setting them in review + // no open claim, create one, update existing + MERGE (resource)<-[:BELONGS_TO]-(claim:Claim {closed: false}) + ON CREATE SET claim.id = randomUUID(), claim.createdAt = $dateTime, claim.updatedAt = claim.createdAt, claim.rule = 'latestReviewUpdatedAtRules', claim.disable = false, claim.closed = false + ON MATCH SET claim.updatedAt = $dateTime + // claim.disable and claim.closed are set after setting them in review - // Create review on caseFolder - WITH moderator, resource, caseFolder - MERGE (caseFolder)<-[review:REVIEWED]-(moderator) + // Create review on claim + WITH moderator, resource, claim + MERGE (claim)<-[review:REVIEWED]-(moderator) ON CREATE SET review.createdAt = $dateTime, review.updatedAt = review.createdAt, review.disable = CASE WHEN $disable IS NULL THEN false @@ -148,10 +148,10 @@ export default { THEN review.closed ELSE $closed END - SET caseFolder.disable = review.disable, caseFolder.closed = review.closed + SET claim.disable = review.disable, claim.closed = review.closed SET resource.disabled = review.disable - RETURN moderator, review, caseFolder {.id}, resource, labels(resource)[0] AS type + RETURN moderator, review, claim {.id}, resource, labels(resource)[0] AS type ` // Wolle console.log('cypher: ', cypher) @@ -184,7 +184,7 @@ export default { return mutateDecisionTransactionResponse.records.map(record => ({ moderator: record.get('moderator'), review: record.get('review'), - caseFolder: record.get('caseFolder'), + claim: record.get('claim'), resource: record.get('resource'), type: record.get('type'), })) @@ -200,11 +200,11 @@ export default { // comment: null, // user: null, // } - const { moderator: moderatorInResult, review, caseFolder, resource, type } = txResult[0] + const { moderator: moderatorInResult, review, claim, resource, type } = txResult[0] createdRelationshipWithNestedAttributes = { ...review.properties, moderator: moderatorInResult.properties, - caseFolderId: caseFolder.id, + claimId: claim.id, type, post: null, comment: null, diff --git a/backend/src/schema/resolvers/reports.js b/backend/src/schema/resolvers/reports.js index c79fef847..b05d82b9d 100644 --- a/backend/src/schema/resolvers/reports.js +++ b/backend/src/schema/resolvers/reports.js @@ -13,14 +13,14 @@ export default { MATCH (submitter:User {id: $submitterId}) MATCH (resource {id: $resourceId}) WHERE resource:User OR resource:Post OR resource:Comment - // no open caseFolder, create one - MERGE (resource)<-[:FLAGGED]-(caseFolder:CaseFolder {closed: false}) - ON CREATE SET caseFolder.id = randomUUID(), caseFolder.createdAt = $createdAt, caseFolder.updatedAt = caseFolder.createdAt, caseFolder.rule = 'latestReviewUpdatedAtRules', caseFolder.disable = false, caseFolder.closed = false - // Create report on caseFolder - WITH submitter, resource, caseFolder - CREATE (caseFolder)<-[report:REPORTED {createdAt: $createdAt, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription}]-(submitter) + // no open claim, create one + MERGE (resource)<-[:BELONGS_TO]-(claim:Claim {closed: false}) + ON CREATE SET claim.id = randomUUID(), claim.createdAt = $createdAt, claim.updatedAt = claim.createdAt, claim.rule = 'latestReviewUpdatedAtRules', claim.disable = false, claim.closed = false + // Create report on claim + WITH submitter, resource, claim + CREATE (claim)<-[report:REPORTED {createdAt: $createdAt, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription}]-(submitter) - RETURN submitter, report, caseFolder, resource, labels(resource)[0] AS type + RETURN submitter, report, claim, resource, labels(resource)[0] AS type `, { resourceId, @@ -33,7 +33,7 @@ export default { return reportRelationshipTransactionResponse.records.map(record => ({ submitter: record.get('submitter'), report: record.get('report'), - caseFolder: record.get('caseFolder'), + claim: record.get('claim'), resource: record.get('resource').properties, type: record.get('type'), })) @@ -41,13 +41,13 @@ export default { try { const txResult = await writeTxResultPromise if (!txResult[0]) return null - const { submitter, report, caseFolder, resource, type } = txResult[0] + const { submitter, report, claim, resource, type } = txResult[0] createdRelationshipWithNestedAttributes = { ...report.properties, - caseFolderId: caseFolder.properties.id, - caseFolderUpdatedAt: caseFolder.properties.updatedAt, - caseFolderDisable: caseFolder.properties.disable, - caseFolderClosed: caseFolder.properties.closed, + claimId: claim.properties.id, + claimUpdatedAt: claim.properties.updatedAt, + claimDisable: claim.properties.disable, + claimClosed: claim.properties.closed, post: null, comment: null, user: null, @@ -89,10 +89,10 @@ export default { } try { const cypher = ` - MATCH (submitter:User)-[report:REPORTED]->(caseFolder:CaseFolder)-[:FLAGGED]->(resource) - // Wolle OPTIONAL MATCH (reviewer:User)-[:REVIEWED]->(caseFolder) + MATCH (submitter:User)-[report:REPORTED]->(claim:Claim)-[:BELONGS_TO]->(resource) + // Wolle OPTIONAL MATCH (reviewer:User)-[:REVIEWED]->(claim) WHERE resource:User OR resource:Post OR resource:Comment - RETURN submitter, report, caseFolder, resource, labels(resource)[0] as type + RETURN submitter, report, claim, resource, labels(resource)[0] as type ${orderByClause} ` const result = await session.run(cypher, {}) @@ -100,7 +100,7 @@ export default { return { submitter: r.get('submitter'), report: r.get('report'), - caseFolder: r.get('caseFolder'), + claim: r.get('claim'), resource: r.get('resource'), type: r.get('type'), } @@ -109,14 +109,14 @@ export default { response = [] dbResponse.forEach(ele => { - const { report, submitter, caseFolder, resource, type } = ele + const { report, submitter, claim, resource, type } = ele const responseEle = { ...report.properties, - caseFolderId: caseFolder.properties.id, - caseFolderUpdatedAt: caseFolder.properties.updatedAt, - caseFolderDisable: caseFolder.properties.disable, - caseFolderClosed: caseFolder.properties.closed, + claimId: claim.properties.id, + claimUpdatedAt: claim.properties.updatedAt, + claimDisable: claim.properties.disable, + claimClosed: claim.properties.closed, post: null, comment: null, user: null, @@ -154,6 +154,6 @@ export default { }, }, REPORTED: { - // Wolle ...undefinedToNullResolver(['caseFolderId', 'caseFolderDisable', 'caseFolderUpdatedAt', 'caseFolderClosed']), + // Wolle ...undefinedToNullResolver(['claimId', 'claimDisable', 'claimUpdatedAt', 'claimClosed']), }, } diff --git a/backend/src/schema/types/type/CaseFolder.gql b/backend/src/schema/types/type/Claim.gql similarity index 51% rename from backend/src/schema/types/type/CaseFolder.gql rename to backend/src/schema/types/type/Claim.gql index ad664302c..23e052308 100644 --- a/backend/src/schema/types/type/CaseFolder.gql +++ b/backend/src/schema/types/type/Claim.gql @@ -1,14 +1,12 @@ -type CaseFolder { +type Claim { id: ID! createdAt: String! updatedAt: String! - rule: CaseRule! + rule: ClaimRule! disable: Boolean! - # reasonCategory: ReasonCategory! - # reasonDescription: String! closed: Boolean! } -enum CaseRule { +enum ClaimRule { latestReviewUpdatedAtRules } diff --git a/backend/src/schema/types/type/Comment.gql b/backend/src/schema/types/type/Comment.gql index dc92c1f9b..1f0404975 100644 --- a/backend/src/schema/types/type/Comment.gql +++ b/backend/src/schema/types/type/Comment.gql @@ -12,9 +12,9 @@ type Comment { reviewedByModerator: User @cypher( statement: """ - MATCH (this)<-[:FLAGGED]-(caseFolder:CaseFolder)<-[review:REVIEWED]-(moderator:User) + MATCH (this)<-[:BELONGS_TO]-(claim:Claim)<-[review:REVIEWED]-(moderator:User) RETURN moderator - ORDER BY caseFolder.updatedAt DESC, review.updatedAt DESC + ORDER BY claim.updatedAt DESC, review.updatedAt DESC LIMIT 1 """ ) diff --git a/backend/src/schema/types/type/Post.gql b/backend/src/schema/types/type/Post.gql index 307312900..dfcb7a0fc 100644 --- a/backend/src/schema/types/type/Post.gql +++ b/backend/src/schema/types/type/Post.gql @@ -124,9 +124,9 @@ type Post { reviewedByModerator: User @cypher( statement: """ - MATCH (this)<-[:FLAGGED]-(caseFolder:CaseFolder)<-[review:REVIEWED]-(moderator:User) + MATCH (this)<-[:BELONGS_TO]-(claim:Claim)<-[review:REVIEWED]-(moderator:User) RETURN moderator - ORDER BY caseFolder.updatedAt DESC, review.updatedAt DESC + ORDER BY claim.updatedAt DESC, review.updatedAt DESC LIMIT 1 """ ) diff --git a/backend/src/schema/types/type/REPORTED.gql b/backend/src/schema/types/type/REPORTED.gql index 1d630e42b..75395de89 100644 --- a/backend/src/schema/types/type/REPORTED.gql +++ b/backend/src/schema/types/type/REPORTED.gql @@ -3,10 +3,10 @@ type REPORTED { reasonCategory: ReasonCategory! reasonDescription: String! - caseFolderId: ID! - caseFolderDisable: Boolean! - caseFolderUpdatedAt: String! - caseFolderClosed: Boolean! + claimId: ID! + claimDisable: Boolean! + claimUpdatedAt: String! + claimClosed: Boolean! # Wolle decision: DECIDED # @cypher(statement: "MATCH (resource)<-[decision:DECIDED {uuid: $decisionUuid}]-(user:User) RETURN decision") diff --git a/backend/src/schema/types/type/REVIEWED.gql b/backend/src/schema/types/type/REVIEWED.gql index d3f064436..52819e7a9 100644 --- a/backend/src/schema/types/type/REVIEWED.gql +++ b/backend/src/schema/types/type/REVIEWED.gql @@ -5,7 +5,7 @@ type REVIEWED { # reasonDescription: String disable: Boolean! closed: Boolean! - caseFolderId: ID! + claimId: ID! # Wolle last: Boolean! moderator: User diff --git a/backend/src/schema/types/type/User.gql b/backend/src/schema/types/type/User.gql index 47635eeb1..13f9d0cd3 100644 --- a/backend/src/schema/types/type/User.gql +++ b/backend/src/schema/types/type/User.gql @@ -36,9 +36,9 @@ type User { reviewedByModerator: User @cypher( statement: """ - MATCH (this)<-[:FLAGGED]-(caseFolder:CaseFolder)<-[review:REVIEWED]-(moderator:User) + MATCH (this)<-[:BELONGS_TO]-(claim:Claim)<-[review:REVIEWED]-(moderator:User) RETURN moderator - ORDER BY caseFolder.updatedAt DESC, review.updatedAt DESC + ORDER BY claim.updatedAt DESC, review.updatedAt DESC LIMIT 1 """ ) diff --git a/neo4j/change_disabled_relationship_to_case_node.sh b/neo4j/change_disabled_relationship_to_case_node.sh index 7671825fc..15d7ce470 100755 --- a/neo4j/change_disabled_relationship_to_case_node.sh +++ b/neo4j/change_disabled_relationship_to_case_node.sh @@ -16,23 +16,23 @@ do done echo " -// convert old DISABLED to new REVIEWED-CaseFolder-FLAGGED structure +// convert old DISABLED to new REVIEWED-Claim-BELONGS_TO structure MATCH (moderator:User)-[disabled:DISABLED]->(disabledResource) WHERE disabledResource:User OR disabledResource:Comment OR disabledResource:Post DELETE disabled -CREATE (moderator)-[review:REVIEWED]->(caseFolder:CaseFolder)-[:FLAGGED]->(disabledResource) +CREATE (moderator)-[review:REVIEWED]->(claim:Claim)-[:BELONGS_TO]->(disabledResource) SET review.createdAt = toString(datetime()), review.updatedAt = review.createdAt, review.disable = true -SET caseFolder.id = randomUUID(), caseFolder.createdAt = toString(datetime()), caseFolder.updatedAt = caseFolder.createdAt, caseFolder.rule = 'latestReviewUpdatedAtRules', caseFolder.disable = true, caseFolder.closed = false +SET claim.id = randomUUID(), claim.createdAt = toString(datetime()), claim.updatedAt = claim.createdAt, claim.rule = 'latestReviewUpdatedAtRules', claim.disable = true, claim.closed = false // if disabledResource has no report, then create a moderators default report -WITH moderator, disabledResource, caseFolder +WITH moderator, disabledResource, claim OPTIONAL MATCH (disabledResourceReporter:User)-[existingReport:REPORTED]->(disabledResource) FOREACH(disabledResource IN CASE WHEN existingReport IS NULL THEN [1] ELSE [] END | - CREATE (moderator)-[addModeratorReport:REPORTED]->(caseFolder) + CREATE (moderator)-[addModeratorReport:REPORTED]->(claim) 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.' ) FOREACH(disabledResource IN CASE WHEN existingReport IS NOT NULL THEN [1] ELSE [] END | - CREATE (disabledResourceReporter)-[moveModeratorReport:REPORTED]->(caseFolder) + CREATE (disabledResourceReporter)-[moveModeratorReport:REPORTED]->(claim) SET moveModeratorReport = existingReport DELETE existingReport ) @@ -41,12 +41,12 @@ RETURN disabledResource {.id}; " | cypher-shell echo " -// for REPORTED resources without DISABLED relation which are handled above, create new REPORTED-CaseFolder-FLAGGED structure +// for REPORTED resources without DISABLED relation which are handled above, create new REPORTED-Claim-BELONGS_TO structure MATCH (reporter:User)-[oldReport:REPORTED]->(notDisabledResource) WHERE notDisabledResource:User OR notDisabledResource:Comment OR notDisabledResource:Post -MERGE (caseFolder:CaseFolder)-[:FLAGGED]->(notDisabledResource) -ON CREATE SET caseFolder.id = randomUUID(), caseFolder.createdAt = toString(datetime()), caseFolder.updatedAt = caseFolder.createdAt, caseFolder.rule = 'latestReviewUpdatedAtRules', caseFolder.disable = false, caseFolder.closed = false -CREATE (reporter)-[report:REPORTED]->(caseFolder) +MERGE (claim:Claim)-[:BELONGS_TO]->(notDisabledResource) +ON CREATE SET claim.id = randomUUID(), claim.createdAt = toString(datetime()), claim.updatedAt = claim.createdAt, claim.rule = 'latestReviewUpdatedAtRules', claim.disable = false, claim.closed = false +CREATE (reporter)-[report:REPORTED]->(claim) SET report = oldReport DELETE oldReport diff --git a/webapp/graphql/Moderation.js b/webapp/graphql/Moderation.js index f11a52a8a..16e471144 100644 --- a/webapp/graphql/Moderation.js +++ b/webapp/graphql/Moderation.js @@ -8,10 +8,10 @@ export const reportListQuery = () => { createdAt reasonCategory reasonDescription - caseFolderId - caseFolderUpdatedAt - caseFolderDisable - caseFolderClosed + claimId + claimUpdatedAt + claimDisable + claimClosed type submitter { id diff --git a/webapp/pages/moderation/index.vue b/webapp/pages/moderation/index.vue index 033a617b1..82c6763c0 100644 --- a/webapp/pages/moderation/index.vue +++ b/webapp/pages/moderation/index.vue @@ -11,7 +11,7 @@