mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Ok, so here are multiple issues: 1. In cypher, `NOT NULL` will return `NULL` not `FALSE`. If we want `FALSE` to be set in the database import, we should use `COAELESCE` to find the first not-null value. See: https://neo4j.com/docs/cypher-manual/current/syntax/working-with-null/ https://markhneedham.com/blog/2017/02/22/neo4j-null-values-even-work/ 2. I removed the `disabled` and `deleted` checks on the commented counter. With `neo4j-graphql-js` it is not possible to filter on the join models (at least not without a lot of complexity) for disabled or deleted items. Let's live with the fact that the list of commented posts will include those posts, where the user has deleted his comment or where the user's comment was disabled. It's being displayed as "not available" so I think this is OK for now. 3. De-couple the pagination counters from the "commented", "shouted" etc. counters. It might be that the list of posts is different for different users. E.g. if the user has blocked you, the "posts" list will be empty. The "shouted" or "commented" list will not have the posts of the author. If you are a moderator, the list will include disabled posts. So the counters are not in sync with the actual list coming from the backend. Therefore I implemented "fetch and check if resultSet < pageSize" instead of a global counter.
154 lines
4.0 KiB
SQL
154 lines
4.0 KiB
SQL
/*
|
|
// Alpha Model
|
|
// [ ] Not modeled in Nitro
|
|
// [X] Modeled in Nitro
|
|
// [-] Omitted in Nitro
|
|
// [?] Unclear / has work to be done for Nitro
|
|
[?] { //Modeled incorrect as Post
|
|
[?] userId: {
|
|
[X] type: String,
|
|
[ ] required: true, // Not required in Nitro
|
|
[-] index: true
|
|
},
|
|
[ ] organizationId: {
|
|
[ ] type: String,
|
|
[-] index: true
|
|
},
|
|
[X] categoryIds: {
|
|
[X] type: Array,
|
|
[-] index: true
|
|
},
|
|
[X] title: {
|
|
[X] type: String,
|
|
[X] required: true
|
|
},
|
|
[?] slug: { // Generated from title
|
|
[X] type: String,
|
|
[ ] required: true, // Not required in Nitro
|
|
[?] unique: true, // Unique value is not enforced in Nitro?
|
|
[-] index: true
|
|
},
|
|
[ ] type: { // db.getCollection('contributions').distinct('type') -> 'DELETED', 'cando', 'post'
|
|
[ ] type: String,
|
|
[ ] required: true,
|
|
[-] index: true
|
|
},
|
|
[ ] cando: {
|
|
[ ] difficulty: {
|
|
[ ] type: String,
|
|
[ ] enum: ['easy', 'medium', 'hard']
|
|
},
|
|
[ ] reasonTitle: { type: String },
|
|
[ ] reason: { type: String }
|
|
},
|
|
[X] content: {
|
|
[X] type: String,
|
|
[X] required: true
|
|
},
|
|
[?] contentExcerpt: { // Generated from content
|
|
[X] type: String,
|
|
[?] required: true // Not required in Nitro
|
|
},
|
|
[ ] hasMore: { type: Boolean },
|
|
[X] teaserImg: { type: String },
|
|
[ ] language: {
|
|
[ ] type: String,
|
|
[ ] required: true,
|
|
[-] index: true
|
|
},
|
|
[ ] shoutCount: {
|
|
[ ] type: Number,
|
|
[ ] default: 0,
|
|
[-] index: true
|
|
},
|
|
[ ] meta: {
|
|
[ ] hasVideo: {
|
|
[ ] type: Boolean,
|
|
[ ] default: false
|
|
},
|
|
[ ] embedds: {
|
|
[ ] type: Object,
|
|
[ ] default: {}
|
|
}
|
|
},
|
|
[?] visibility: {
|
|
[X] type: String,
|
|
[X] enum: ['public', 'friends', 'private'],
|
|
[ ] default: 'public', // Default value is missing in Nitro
|
|
[-] index: true
|
|
},
|
|
[?] isEnabled: {
|
|
[X] type: Boolean,
|
|
[ ] default: true, // Default value is missing in Nitro
|
|
[-] index: true
|
|
},
|
|
[?] tags: { type: Array }, // ensure this is working properly
|
|
[ ] emotions: {
|
|
[ ] type: Object,
|
|
[-] index: true,
|
|
[ ] default: {
|
|
[ ] angry: {
|
|
[ ] count: 0,
|
|
[ ] percent: 0
|
|
[ ] },
|
|
[ ] cry: {
|
|
[ ] count: 0,
|
|
[ ] percent: 0
|
|
[ ] },
|
|
[ ] surprised: {
|
|
[ ] count: 0,
|
|
[ ] percent: 0
|
|
},
|
|
[ ] happy: {
|
|
[ ] count: 0,
|
|
[ ] percent: 0
|
|
},
|
|
[ ] funny: {
|
|
[ ] count: 0,
|
|
[ ] percent: 0
|
|
}
|
|
}
|
|
},
|
|
[?] deleted: { // THis field is not always present in the alpha-data
|
|
[?] type: Boolean,
|
|
[ ] default: false, // Default value is missing in Nitro
|
|
[-] index: true
|
|
},
|
|
[?] createdAt: {
|
|
[?] type: Date, // Type is modeled as string in Nitro which is incorrect
|
|
[ ] default: Date.now // Default value is missing in Nitro
|
|
},
|
|
[?] updatedAt: {
|
|
[?] type: Date, // Type is modeled as string in Nitro which is incorrect
|
|
[ ] default: Date.now // Default value is missing in Nitro
|
|
},
|
|
[ ] wasSeeded: { type: Boolean }
|
|
}
|
|
*/
|
|
|
|
CALL apoc.load.json("file:${IMPORT_CHUNK_PATH_CQL_FILE}") YIELD value as post
|
|
MERGE (p:Post {id: post._id["$oid"]})
|
|
ON CREATE SET
|
|
p.title = post.title,
|
|
p.slug = post.slug,
|
|
p.image = replace(post.teaserImg, 'https://api-alpha.human-connection.org', ''),
|
|
p.content = post.content,
|
|
p.contentExcerpt = post.contentExcerpt,
|
|
p.visibility = toLower(post.visibility),
|
|
p.createdAt = post.createdAt.`$date`,
|
|
p.updatedAt = post.updatedAt.`$date`,
|
|
p.deleted = COALESCE(post.deleted, false),
|
|
p.disabled = COALESCE(NOT post.isEnabled, false)
|
|
WITH p, post
|
|
MATCH (u:User {id: post.userId})
|
|
MERGE (u)-[:WROTE]->(p)
|
|
WITH p, post, post.categoryIds as categoryIds
|
|
UNWIND categoryIds AS categoryId
|
|
MATCH (c:Category {id: categoryId})
|
|
MERGE (p)-[:CATEGORIZED]->(c)
|
|
WITH p, post.tags AS tags
|
|
UNWIND tags AS tag
|
|
MERGE (t:Tag {id: apoc.text.clean(tag), disabled: false, deleted: false})
|
|
MERGE (p)-[:TAGGED]->(t)
|
|
;
|