mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge pull request #944 from Human-Connection/2019/kw27/data_import_emotions
🍰 2019/kw27/data_import_emotions
This commit is contained in:
commit
e2eba389cc
7
backend/src/schema/types/enum/Emotion.gql
Normal file
7
backend/src/schema/types/enum/Emotion.gql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
enum Emotion {
|
||||||
|
surprised
|
||||||
|
cry
|
||||||
|
happy
|
||||||
|
angry
|
||||||
|
funny
|
||||||
|
}
|
||||||
10
backend/src/schema/types/type/EMOTED.gql
Normal file
10
backend/src/schema/types/type/EMOTED.gql
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type EMOTED @relation(name: "EMOTED") {
|
||||||
|
from: User
|
||||||
|
to: Post
|
||||||
|
|
||||||
|
emotion: Emotion
|
||||||
|
#createdAt: DateTime
|
||||||
|
#updatedAt: DateTime
|
||||||
|
createdAt: String
|
||||||
|
updatedAt: String
|
||||||
|
}
|
||||||
@ -48,6 +48,8 @@ type Post {
|
|||||||
RETURN COUNT(u) >= 1
|
RETURN COUNT(u) >= 1
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
emotions: [EMOTED]
|
||||||
}
|
}
|
||||||
|
|
||||||
type Mutation {
|
type Mutation {
|
||||||
|
|||||||
@ -73,6 +73,8 @@ type User {
|
|||||||
|
|
||||||
badges: [Badge]! @relation(name: "REWARDED", direction: "IN")
|
badges: [Badge]! @relation(name: "REWARDED", direction: "IN")
|
||||||
badgesCount: Int! @cypher(statement: "MATCH (this)<-[:REWARDED]-(r:Badge) RETURN COUNT(r)")
|
badgesCount: Int! @cypher(statement: "MATCH (this)<-[:REWARDED]-(r:Badge) RETURN COUNT(r)")
|
||||||
|
|
||||||
|
emotions: [EMOTED]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
MATCH (u:User)-[e:EMOTED]->(c:Post) DETACH DELETE e;
|
||||||
@ -5,31 +5,54 @@
|
|||||||
// [-] Omitted in Nitro
|
// [-] Omitted in Nitro
|
||||||
// [?] Unclear / has work to be done for Nitro
|
// [?] Unclear / has work to be done for Nitro
|
||||||
{
|
{
|
||||||
[ ] userId: {
|
[X] userId: {
|
||||||
[ ] type: String,
|
[X] type: String,
|
||||||
[ ] required: true,
|
[X] required: true,
|
||||||
[-] index: true
|
[-] index: true
|
||||||
},
|
},
|
||||||
[ ] contributionId: {
|
[X] contributionId: {
|
||||||
[ ] type: String,
|
[X] type: String,
|
||||||
[ ] required: true,
|
[X] required: true,
|
||||||
[-] index: true
|
[-] index: true
|
||||||
},
|
},
|
||||||
[ ] rated: {
|
[?] rated: {
|
||||||
[ ] type: String,
|
[X] type: String,
|
||||||
[ ] required: true,
|
[ ] required: true,
|
||||||
[ ] enum: ['funny', 'happy', 'surprised', 'cry', 'angry']
|
[?] enum: ['funny', 'happy', 'surprised', 'cry', 'angry']
|
||||||
},
|
},
|
||||||
[ ] createdAt: {
|
[X] createdAt: {
|
||||||
[ ] type: Date,
|
[X] type: Date,
|
||||||
[ ] default: Date.now
|
[X] default: Date.now
|
||||||
},
|
},
|
||||||
[ ] updatedAt: {
|
[X] updatedAt: {
|
||||||
[ ] type: Date,
|
[X] type: Date,
|
||||||
[ ] default: Date.now
|
[X] default: Date.now
|
||||||
},
|
},
|
||||||
[ ] wasSeeded: { type: Boolean }
|
[-] wasSeeded: { type: Boolean }
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CALL apoc.load.json("file:${IMPORT_CHUNK_PATH_CQL_FILE}") YIELD value as emotion;
|
CALL apoc.load.json("file:${IMPORT_CHUNK_PATH_CQL_FILE}") YIELD value as emotion
|
||||||
|
MATCH (u:User {id: emotion.userId}),
|
||||||
|
(c:Post {id: emotion.contributionId})
|
||||||
|
MERGE (u)-[e:EMOTED {
|
||||||
|
id: emotion._id["$oid"],
|
||||||
|
emotion: emotion.rated,
|
||||||
|
createdAt: datetime(emotion.createdAt.`$date`),
|
||||||
|
updatedAt: datetime(emotion.updatedAt.`$date`)
|
||||||
|
}]->(c)
|
||||||
|
RETURN e;
|
||||||
|
/*
|
||||||
|
// Queries
|
||||||
|
// user sets an emotion emotion:
|
||||||
|
// MERGE (u)-[e:EMOTED {id: ..., emotion: "funny", createdAt: ..., updatedAt: ...}]->(c)
|
||||||
|
// user removes emotion
|
||||||
|
// MATCH (u)-[e:EMOTED]->(c) DELETE e
|
||||||
|
// contribution distributions over every `emotion` property value for one post
|
||||||
|
// MATCH (u:User)-[e:EMOTED]->(c:Post {id: "5a70bbc8508f5b000b443b1a"}) RETURN e.emotion,COUNT(e.emotion)
|
||||||
|
// contribution distributions over every `emotion` property value for one user (advanced - "whats the primary emotion used by the user?")
|
||||||
|
// MATCH (u:User{id:"5a663b1ac64291000bf302a1"})-[e:EMOTED]->(c:Post) RETURN e.emotion,COUNT(e.emotion)
|
||||||
|
// contribution distributions over every `emotion` property value for all posts created by one user (advanced - "how do others react to my contributions?")
|
||||||
|
// MATCH (u:User)-[e:EMOTED]->(c:Post)<-[w:WROTE]-(a:User{id:"5a663b1ac64291000bf302a1"}) RETURN e.emotion,COUNT(e.emotion)
|
||||||
|
// if we can filter the above an a variable timescale that would be great (should be possible on createdAt and updatedAt fields)
|
||||||
|
*/
|
||||||
@ -1 +1 @@
|
|||||||
// this is just a relation between users(?) - no need to delete
|
MATCH (u1:User)-[f:FOLLOWS]->(u2:User) DETACH DELETE f;
|
||||||
@ -60,8 +60,8 @@ delete_collection "contributions" "contributions_post"
|
|||||||
delete_collection "contributions" "contributions_cando"
|
delete_collection "contributions" "contributions_cando"
|
||||||
delete_collection "shouts" "shouts"
|
delete_collection "shouts" "shouts"
|
||||||
delete_collection "comments" "comments"
|
delete_collection "comments" "comments"
|
||||||
|
delete_collection "emotions" "emotions"
|
||||||
|
|
||||||
#delete_collection "emotions"
|
|
||||||
#delete_collection "invites"
|
#delete_collection "invites"
|
||||||
#delete_collection "notifications"
|
#delete_collection "notifications"
|
||||||
#delete_collection "organizations"
|
#delete_collection "organizations"
|
||||||
@ -82,12 +82,12 @@ import_collection "users" "users/users.cql"
|
|||||||
import_collection "follows_users" "follows/follows.cql"
|
import_collection "follows_users" "follows/follows.cql"
|
||||||
#import_collection "follows_organizations" "follows/follows.cql"
|
#import_collection "follows_organizations" "follows/follows.cql"
|
||||||
import_collection "contributions_post" "contributions/contributions.cql"
|
import_collection "contributions_post" "contributions/contributions.cql"
|
||||||
import_collection "contributions_cando" "contributions/contributions.cql"
|
#import_collection "contributions_cando" "contributions/contributions.cql"
|
||||||
#import_collection "contributions_DELETED" "contributions/contributions.cql"
|
#import_collection "contributions_DELETED" "contributions/contributions.cql"
|
||||||
import_collection "shouts" "shouts/shouts.cql"
|
import_collection "shouts" "shouts/shouts.cql"
|
||||||
import_collection "comments" "comments/comments.cql"
|
import_collection "comments" "comments/comments.cql"
|
||||||
|
import_collection "emotions" "emotions/emotions.cql"
|
||||||
|
|
||||||
# import_collection "emotions"
|
|
||||||
# import_collection "invites"
|
# import_collection "invites"
|
||||||
# import_collection "notifications"
|
# import_collection "notifications"
|
||||||
# import_collection "organizations"
|
# import_collection "organizations"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user