From 66ed78e19b06dcf7bfe27e861d915827ba33f4c6 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Thu, 5 Sep 2019 03:19:58 +0200 Subject: [PATCH] Remove a lot of unused code, reduce graphql schema --- backend/src/middleware/dateTimeMiddleware.js | 2 -- backend/src/middleware/excerptMiddleware.js | 10 ------- backend/src/middleware/sluggifyMiddleware.js | 4 --- backend/src/schema/index.js | 9 ++++++ backend/src/schema/resolvers/statistics.js | 16 ++-------- backend/src/schema/resolvers/users.js | 3 +- backend/src/schema/types/schema.gql | 21 ------------- backend/src/schema/types/type/EMOTED.gql | 11 +++++++ backend/src/schema/types/type/Post.gql | 5 ++++ backend/src/schema/types/type/Tag.gql | 1 - backend/src/schema/types/type/User.gql | 5 +--- .../migration/mongo/export.sh | 20 ++++++------- neo4j/db_setup.sh | 2 -- webapp/pages/admin/index.vue | 30 ------------------- 14 files changed, 39 insertions(+), 100 deletions(-) diff --git a/backend/src/middleware/dateTimeMiddleware.js b/backend/src/middleware/dateTimeMiddleware.js index ff1fcc996..e8bd27306 100644 --- a/backend/src/middleware/dateTimeMiddleware.js +++ b/backend/src/middleware/dateTimeMiddleware.js @@ -11,10 +11,8 @@ export default { Mutation: { CreatePost: setCreatedAt, CreateComment: setCreatedAt, - CreateOrganization: setCreatedAt, UpdateUser: setUpdatedAt, UpdatePost: setUpdatedAt, UpdateComment: setUpdatedAt, - UpdateOrganization: setUpdatedAt, }, } diff --git a/backend/src/middleware/excerptMiddleware.js b/backend/src/middleware/excerptMiddleware.js index 3b3a27c2c..40a6a6ae4 100644 --- a/backend/src/middleware/excerptMiddleware.js +++ b/backend/src/middleware/excerptMiddleware.js @@ -22,15 +22,5 @@ export default { const result = await resolve(root, args, context, info) return result }, - CreateOrganization: async (resolve, root, args, context, info) => { - args.descriptionExcerpt = trunc(args.description, 120).html - const result = await resolve(root, args, context, info) - return result - }, - UpdateOrganization: async (resolve, root, args, context, info) => { - args.descriptionExcerpt = trunc(args.description, 120).html - const result = await resolve(root, args, context, info) - return result - }, }, } diff --git a/backend/src/middleware/sluggifyMiddleware.js b/backend/src/middleware/sluggifyMiddleware.js index 6133a3c14..03d7f8584 100644 --- a/backend/src/middleware/sluggifyMiddleware.js +++ b/backend/src/middleware/sluggifyMiddleware.js @@ -25,10 +25,6 @@ export default { args.slug = args.slug || (await uniqueSlug(args.title, isUniqueFor(context, 'Post'))) return resolve(root, args, context, info) }, - CreateOrganization: async (resolve, root, args, context, info) => { - args.slug = args.slug || (await uniqueSlug(args.name, isUniqueFor(context, 'Organization'))) - return resolve(root, args, context, info) - }, CreateCategory: async (resolve, root, args, context, info) => { args.slug = args.slug || (await uniqueSlug(args.name, isUniqueFor(context, 'Category'))) return resolve(root, args, context, info) diff --git a/backend/src/schema/index.js b/backend/src/schema/index.js index e8fa63d97..4d1b9574e 100644 --- a/backend/src/schema/index.js +++ b/backend/src/schema/index.js @@ -14,11 +14,13 @@ export default applyScalars( query: { exclude: [ 'Badge', + 'Embed', 'InvitationCode', 'EmailAddress', 'Notfication', 'Statistics', 'LoggedInUser', + 'Location', 'SocialMedia', 'NOTIFIED', ], @@ -27,12 +29,19 @@ export default applyScalars( mutation: { exclude: [ 'Badge', + 'Embed', 'InvitationCode', 'EmailAddress', 'Notfication', + 'Post', + 'Comment', + 'Report', 'Statistics', 'LoggedInUser', + 'Location', 'SocialMedia', + 'User', + 'EMOTED', 'NOTIFIED', ], // add 'User' here as soon as possible diff --git a/backend/src/schema/resolvers/statistics.js b/backend/src/schema/resolvers/statistics.js index 982c2acfa..db6e205d2 100644 --- a/backend/src/schema/resolvers/statistics.js +++ b/backend/src/schema/resolvers/statistics.js @@ -43,14 +43,8 @@ export default { 'MATCH (r:Post) WHERE r.deleted <> true OR NOT exists(r.deleted) RETURN COUNT(r) AS countPosts', countComments: 'MATCH (r:Comment) WHERE r.deleted <> true OR NOT exists(r.deleted) RETURN COUNT(r) AS countComments', - countNotifications: - 'MATCH (r:Notification) WHERE r.deleted <> true OR NOT exists(r.deleted) RETURN COUNT(r) AS countNotifications', - countOrganizations: - 'MATCH (r:Organization) WHERE r.deleted <> true OR NOT exists(r.deleted) RETURN COUNT(r) AS countOrganizations', - countProjects: - 'MATCH (r:Project) WHERE r.deleted <> true OR NOT exists(r.deleted) RETURN COUNT(r) AS countProjects', - countInvites: - 'MATCH (r:Invite) WHERE r.wasUsed <> true OR NOT exists(r.wasUsed) RETURN COUNT(r) AS countInvites', + countNotifications: 'MATCH ()-[r:NOTIFIED]->() RETURN COUNT(r) AS countNotifications', + countInvites: 'MATCH (r:InvitationCode) RETURN COUNT(r) AS countInvites', countFollows: 'MATCH (:User)-[r:FOLLOWS]->(:User) RETURN COUNT(r) AS countFollows', countShouts: 'MATCH (:User)-[r:SHOUTED]->(:Post) RETURN COUNT(r) AS countShouts', } @@ -63,12 +57,6 @@ export default { countNotifications: queryOne(queries.countNotifications, session).then( res => res.countNotifications.low, ), - countOrganizations: queryOne(queries.countOrganizations, session).then( - res => res.countOrganizations.low, - ), - countProjects: queryOne(queries.countProjects, session).then( - res => res.countProjects.low, - ), countInvites: queryOne(queries.countInvites, session).then(res => res.countInvites.low), countFollows: queryOne(queries.countFollows, session).then(res => res.countFollows.low), countShouts: queryOne(queries.countShouts, session).then(res => res.countShouts.low), diff --git a/backend/src/schema/resolvers/users.js b/backend/src/schema/resolvers/users.js index 93076e334..267f578f8 100644 --- a/backend/src/schema/resolvers/users.js +++ b/backend/src/schema/resolvers/users.js @@ -165,6 +165,7 @@ export default { }, ...Resolver('User', { undefinedToNull: [ + 'termsAndConditionsAgreedVersion', 'actorId', 'avatar', 'coverImg', @@ -204,8 +205,6 @@ export default { contributions: '-[:WROTE]->(related:Post)', comments: '-[:WROTE]->(related:Comment)', shouted: '-[:SHOUTED]->(related:Post)', - organizationsCreated: '-[:CREATED_ORGA]->(related:Organization)', - organizationsOwned: '-[:OWNING_ORGA]->(related:Organization)', categories: '-[:CATEGORIZED]->(related:Category)', badges: '<-[:REWARDED]-(related:Badge)', }, diff --git a/backend/src/schema/types/schema.gql b/backend/src/schema/types/schema.gql index dc2cec8f5..7aa04ea57 100644 --- a/backend/src/schema/types/schema.gql +++ b/backend/src/schema/types/schema.gql @@ -44,8 +44,6 @@ type Statistics { countPosts: Int! countComments: Int! countNotifications: Int! - countOrganizations: Int! - countProjects: Int! countInvites: Int! countFollows: Int! countShouts: Int! @@ -70,13 +68,9 @@ enum Deletable { enum ShoutTypeEnum { Post - Organization - Project } enum FollowTypeEnum { User - Organization - Project } type Reward { @@ -87,21 +81,6 @@ type Reward { badge: Badge @relation(name: "REWARDED", direction: "OUT") } -type Organization { - id: ID! - createdBy: User @relation(name: "CREATED_ORGA", direction: "IN") - ownedBy: [User] @relation(name: "OWNING_ORGA", direction: "IN") - name: String! - slug: String - description: String! - descriptionExcerpt: String - deleted: Boolean - disabled: Boolean - - tags: [Tag]! @relation(name: "TAGGED", direction: "OUT") - categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT") -} - type SharedInboxEndpoint { id: ID! uri: String diff --git a/backend/src/schema/types/type/EMOTED.gql b/backend/src/schema/types/type/EMOTED.gql index d40eed0c4..cb8d37d62 100644 --- a/backend/src/schema/types/type/EMOTED.gql +++ b/backend/src/schema/types/type/EMOTED.gql @@ -8,3 +8,14 @@ type EMOTED @relation(name: "EMOTED") { createdAt: String updatedAt: String } + +input _EMOTEDInput { + emotion: Emotion + createdAt: String + updatedAt: String +} + +type Mutation { + AddPostEmotions(to: _PostInput!, data: _EMOTEDInput!): EMOTED + RemovePostEmotions(to: _PostInput!, data: _EMOTEDInput!): EMOTED +} diff --git a/backend/src/schema/types/type/Post.gql b/backend/src/schema/types/type/Post.gql index 0e1121cd2..5b11757d3 100644 --- a/backend/src/schema/types/type/Post.gql +++ b/backend/src/schema/types/type/Post.gql @@ -52,6 +52,10 @@ type Post { @cypher(statement: "MATCH (this)<-[emoted:EMOTED]-(:User) RETURN COUNT(DISTINCT emoted)") } +input _PostInput { + id: ID! +} + type Mutation { CreatePost( id: ID @@ -77,6 +81,7 @@ type Mutation { language: String categoryIds: [ID] ): Post + DeletePost(id: ID!): Post AddPostEmotions(to: _PostInput!, data: _EMOTEDInput!): EMOTED RemovePostEmotions(to: _PostInput!, data: _EMOTEDInput!): EMOTED } diff --git a/backend/src/schema/types/type/Tag.gql b/backend/src/schema/types/type/Tag.gql index c9c36343a..84c6ee7e7 100644 --- a/backend/src/schema/types/type/Tag.gql +++ b/backend/src/schema/types/type/Tag.gql @@ -1,7 +1,6 @@ type Tag { id: ID! taggedPosts: [Post]! @relation(name: "TAGGED", direction: "IN") - taggedOrganizations: [Organization]! @relation(name: "TAGGED", direction: "IN") taggedCount: Int! @cypher(statement: "MATCH (this)<-[:TAGGED]-(p) RETURN COUNT(DISTINCT p)") taggedCountUnique: Int! @cypher(statement: "MATCH (this)<-[:TAGGED]-(p)<-[:WROTE]-(u:User) RETURN COUNT(DISTINCT u)") deleted: Boolean diff --git a/backend/src/schema/types/type/User.gql b/backend/src/schema/types/type/User.gql index 83d5343b2..1c1b9041d 100644 --- a/backend/src/schema/types/type/User.gql +++ b/backend/src/schema/types/type/User.gql @@ -69,9 +69,6 @@ type User { shouted: [Post]! @relation(name: "SHOUTED", direction: "OUT") shoutedCount: Int! @cypher(statement: "MATCH (this)-[: SHOUTED]->(r: Post) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(DISTINCT r)") - organizationsCreated: [Organization] @relation(name: "CREATED_ORGA", direction: "OUT") - organizationsOwned: [Organization] @relation(name: "OWNING_ORGA", direction: "OUT") - categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT") badges: [Badge]! @relation(name: "REWARDED", direction: "IN") @@ -174,4 +171,4 @@ type Mutation { block(id: ID!): User unblock(id: ID!): User -} \ No newline at end of file +} diff --git a/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh b/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh index f80ea8b8b..180105308 100755 --- a/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh +++ b/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh @@ -33,20 +33,20 @@ export_collection "categories" export_collection "comments" export_collection_query "contributions" "{'type': 'DELETED'}" "DELETED" export_collection_query "contributions" "{'type': 'post'}" "post" -export_collection_query "contributions" "{'type': 'cando'}" "cando" +# export_collection_query "contributions" "{'type': 'cando'}" "cando" export_collection "emotions" -export_collection_query "follows" "{'foreignService': 'organizations'}" "organizations" +# export_collection_query "follows" "{'foreignService': 'organizations'}" "organizations" export_collection_query "follows" "{'foreignService': 'users'}" "users" -export_collection "invites" -export_collection "organizations" -export_collection "pages" -export_collection "projects" -export_collection "settings" +# export_collection "invites" +# export_collection "organizations" +# export_collection "pages" +# export_collection "projects" +# export_collection "settings" export_collection "shouts" -export_collection "status" +# export_collection "status" export_collection "users" -export_collection "userscandos" -export_collection "usersettings" +# export_collection "userscandos" +# export_collection "usersettings" # Close SSH Tunnel ssh -S my-ctrl-socket -O check -l ${SSH_USERNAME} ${SSH_HOST} diff --git a/neo4j/db_setup.sh b/neo4j/db_setup.sh index 51276cf39..ba90ee5f4 100755 --- a/neo4j/db_setup.sh +++ b/neo4j/db_setup.sh @@ -26,13 +26,11 @@ CREATE CONSTRAINT ON (p:Post) ASSERT p.id IS UNIQUE; CREATE CONSTRAINT ON (c:Comment) ASSERT c.id IS UNIQUE; CREATE CONSTRAINT ON (c:Category) ASSERT c.id IS UNIQUE; CREATE CONSTRAINT ON (u:User) ASSERT u.id IS UNIQUE; -CREATE CONSTRAINT ON (o:Organization) ASSERT o.id IS UNIQUE; CREATE CONSTRAINT ON (t:Tag) ASSERT t.id IS UNIQUE; CREATE CONSTRAINT ON (p:Post) ASSERT p.slug IS UNIQUE; CREATE CONSTRAINT ON (c:Category) ASSERT c.slug IS UNIQUE; CREATE CONSTRAINT ON (u:User) ASSERT u.slug IS UNIQUE; -CREATE CONSTRAINT ON (o:Organization) ASSERT o.slug IS UNIQUE; CREATE CONSTRAINT ON (e:EmailAddress) ASSERT e.email IS UNIQUE; ' | cypher-shell diff --git a/webapp/pages/admin/index.vue b/webapp/pages/admin/index.vue index f764238e3..17d756fbd 100644 --- a/webapp/pages/admin/index.vue +++ b/webapp/pages/admin/index.vue @@ -49,34 +49,6 @@ - - - - - - - - - - - - - - - - - - @@ -137,8 +109,6 @@ export default { countPosts countComments countNotifications - countOrganizations - countProjects countInvites countFollows countShouts