Remove a lot of unused code, reduce graphql schema

This commit is contained in:
roschaefer 2019-09-05 03:19:58 +02:00
parent 127d98c475
commit 66ed78e19b
14 changed files with 39 additions and 100 deletions

View File

@ -11,10 +11,8 @@ export default {
Mutation: { Mutation: {
CreatePost: setCreatedAt, CreatePost: setCreatedAt,
CreateComment: setCreatedAt, CreateComment: setCreatedAt,
CreateOrganization: setCreatedAt,
UpdateUser: setUpdatedAt, UpdateUser: setUpdatedAt,
UpdatePost: setUpdatedAt, UpdatePost: setUpdatedAt,
UpdateComment: setUpdatedAt, UpdateComment: setUpdatedAt,
UpdateOrganization: setUpdatedAt,
}, },
} }

View File

@ -22,15 +22,5 @@ export default {
const result = await resolve(root, args, context, info) const result = await resolve(root, args, context, info)
return result 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
},
}, },
} }

View File

@ -25,10 +25,6 @@ export default {
args.slug = args.slug || (await uniqueSlug(args.title, isUniqueFor(context, 'Post'))) args.slug = args.slug || (await uniqueSlug(args.title, isUniqueFor(context, 'Post')))
return resolve(root, args, context, info) 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) => { CreateCategory: async (resolve, root, args, context, info) => {
args.slug = args.slug || (await uniqueSlug(args.name, isUniqueFor(context, 'Category'))) args.slug = args.slug || (await uniqueSlug(args.name, isUniqueFor(context, 'Category')))
return resolve(root, args, context, info) return resolve(root, args, context, info)

View File

@ -14,11 +14,13 @@ export default applyScalars(
query: { query: {
exclude: [ exclude: [
'Badge', 'Badge',
'Embed',
'InvitationCode', 'InvitationCode',
'EmailAddress', 'EmailAddress',
'Notfication', 'Notfication',
'Statistics', 'Statistics',
'LoggedInUser', 'LoggedInUser',
'Location',
'SocialMedia', 'SocialMedia',
'NOTIFIED', 'NOTIFIED',
], ],
@ -27,12 +29,19 @@ export default applyScalars(
mutation: { mutation: {
exclude: [ exclude: [
'Badge', 'Badge',
'Embed',
'InvitationCode', 'InvitationCode',
'EmailAddress', 'EmailAddress',
'Notfication', 'Notfication',
'Post',
'Comment',
'Report',
'Statistics', 'Statistics',
'LoggedInUser', 'LoggedInUser',
'Location',
'SocialMedia', 'SocialMedia',
'User',
'EMOTED',
'NOTIFIED', 'NOTIFIED',
], ],
// add 'User' here as soon as possible // add 'User' here as soon as possible

View File

@ -43,14 +43,8 @@ export default {
'MATCH (r:Post) WHERE r.deleted <> true OR NOT exists(r.deleted) RETURN COUNT(r) AS countPosts', 'MATCH (r:Post) WHERE r.deleted <> true OR NOT exists(r.deleted) RETURN COUNT(r) AS countPosts',
countComments: countComments:
'MATCH (r:Comment) WHERE r.deleted <> true OR NOT exists(r.deleted) RETURN COUNT(r) AS countComments', 'MATCH (r:Comment) WHERE r.deleted <> true OR NOT exists(r.deleted) RETURN COUNT(r) AS countComments',
countNotifications: countNotifications: 'MATCH ()-[r:NOTIFIED]->() RETURN COUNT(r) AS countNotifications',
'MATCH (r:Notification) WHERE r.deleted <> true OR NOT exists(r.deleted) RETURN COUNT(r) AS countNotifications', countInvites: 'MATCH (r:InvitationCode) RETURN COUNT(r) AS countInvites',
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',
countFollows: 'MATCH (:User)-[r:FOLLOWS]->(:User) RETURN COUNT(r) AS countFollows', countFollows: 'MATCH (:User)-[r:FOLLOWS]->(:User) RETURN COUNT(r) AS countFollows',
countShouts: 'MATCH (:User)-[r:SHOUTED]->(:Post) RETURN COUNT(r) AS countShouts', countShouts: 'MATCH (:User)-[r:SHOUTED]->(:Post) RETURN COUNT(r) AS countShouts',
} }
@ -63,12 +57,6 @@ export default {
countNotifications: queryOne(queries.countNotifications, session).then( countNotifications: queryOne(queries.countNotifications, session).then(
res => res.countNotifications.low, 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), countInvites: queryOne(queries.countInvites, session).then(res => res.countInvites.low),
countFollows: queryOne(queries.countFollows, session).then(res => res.countFollows.low), countFollows: queryOne(queries.countFollows, session).then(res => res.countFollows.low),
countShouts: queryOne(queries.countShouts, session).then(res => res.countShouts.low), countShouts: queryOne(queries.countShouts, session).then(res => res.countShouts.low),

View File

@ -165,6 +165,7 @@ export default {
}, },
...Resolver('User', { ...Resolver('User', {
undefinedToNull: [ undefinedToNull: [
'termsAndConditionsAgreedVersion',
'actorId', 'actorId',
'avatar', 'avatar',
'coverImg', 'coverImg',
@ -204,8 +205,6 @@ export default {
contributions: '-[:WROTE]->(related:Post)', contributions: '-[:WROTE]->(related:Post)',
comments: '-[:WROTE]->(related:Comment)', comments: '-[:WROTE]->(related:Comment)',
shouted: '-[:SHOUTED]->(related:Post)', shouted: '-[:SHOUTED]->(related:Post)',
organizationsCreated: '-[:CREATED_ORGA]->(related:Organization)',
organizationsOwned: '-[:OWNING_ORGA]->(related:Organization)',
categories: '-[:CATEGORIZED]->(related:Category)', categories: '-[:CATEGORIZED]->(related:Category)',
badges: '<-[:REWARDED]-(related:Badge)', badges: '<-[:REWARDED]-(related:Badge)',
}, },

View File

@ -44,8 +44,6 @@ type Statistics {
countPosts: Int! countPosts: Int!
countComments: Int! countComments: Int!
countNotifications: Int! countNotifications: Int!
countOrganizations: Int!
countProjects: Int!
countInvites: Int! countInvites: Int!
countFollows: Int! countFollows: Int!
countShouts: Int! countShouts: Int!
@ -70,13 +68,9 @@ enum Deletable {
enum ShoutTypeEnum { enum ShoutTypeEnum {
Post Post
Organization
Project
} }
enum FollowTypeEnum { enum FollowTypeEnum {
User User
Organization
Project
} }
type Reward { type Reward {
@ -87,21 +81,6 @@ type Reward {
badge: Badge @relation(name: "REWARDED", direction: "OUT") 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 { type SharedInboxEndpoint {
id: ID! id: ID!
uri: String uri: String

View File

@ -8,3 +8,14 @@ type EMOTED @relation(name: "EMOTED") {
createdAt: String createdAt: String
updatedAt: 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
}

View File

@ -52,6 +52,10 @@ type Post {
@cypher(statement: "MATCH (this)<-[emoted:EMOTED]-(:User) RETURN COUNT(DISTINCT emoted)") @cypher(statement: "MATCH (this)<-[emoted:EMOTED]-(:User) RETURN COUNT(DISTINCT emoted)")
} }
input _PostInput {
id: ID!
}
type Mutation { type Mutation {
CreatePost( CreatePost(
id: ID id: ID
@ -77,6 +81,7 @@ type Mutation {
language: String language: String
categoryIds: [ID] categoryIds: [ID]
): Post ): Post
DeletePost(id: ID!): Post
AddPostEmotions(to: _PostInput!, data: _EMOTEDInput!): EMOTED AddPostEmotions(to: _PostInput!, data: _EMOTEDInput!): EMOTED
RemovePostEmotions(to: _PostInput!, data: _EMOTEDInput!): EMOTED RemovePostEmotions(to: _PostInput!, data: _EMOTEDInput!): EMOTED
} }

View File

@ -1,7 +1,6 @@
type Tag { type Tag {
id: ID! id: ID!
taggedPosts: [Post]! @relation(name: "TAGGED", direction: "IN") 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)") 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)") taggedCountUnique: Int! @cypher(statement: "MATCH (this)<-[:TAGGED]-(p)<-[:WROTE]-(u:User) RETURN COUNT(DISTINCT u)")
deleted: Boolean deleted: Boolean

View File

@ -69,9 +69,6 @@ type User {
shouted: [Post]! @relation(name: "SHOUTED", direction: "OUT") 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)") 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") categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT")
badges: [Badge]! @relation(name: "REWARDED", direction: "IN") badges: [Badge]! @relation(name: "REWARDED", direction: "IN")
@ -174,4 +171,4 @@ type Mutation {
block(id: ID!): User block(id: ID!): User
unblock(id: ID!): User unblock(id: ID!): User
} }

View File

@ -33,20 +33,20 @@ export_collection "categories"
export_collection "comments" export_collection "comments"
export_collection_query "contributions" "{'type': 'DELETED'}" "DELETED" export_collection_query "contributions" "{'type': 'DELETED'}" "DELETED"
export_collection_query "contributions" "{'type': 'post'}" "post" 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 "emotions"
export_collection_query "follows" "{'foreignService': 'organizations'}" "organizations" # export_collection_query "follows" "{'foreignService': 'organizations'}" "organizations"
export_collection_query "follows" "{'foreignService': 'users'}" "users" export_collection_query "follows" "{'foreignService': 'users'}" "users"
export_collection "invites" # export_collection "invites"
export_collection "organizations" # export_collection "organizations"
export_collection "pages" # export_collection "pages"
export_collection "projects" # export_collection "projects"
export_collection "settings" # export_collection "settings"
export_collection "shouts" export_collection "shouts"
export_collection "status" # export_collection "status"
export_collection "users" export_collection "users"
export_collection "userscandos" # export_collection "userscandos"
export_collection "usersettings" # export_collection "usersettings"
# Close SSH Tunnel # Close SSH Tunnel
ssh -S my-ctrl-socket -O check -l ${SSH_USERNAME} ${SSH_HOST} ssh -S my-ctrl-socket -O check -l ${SSH_USERNAME} ${SSH_HOST}

View File

@ -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:Comment) ASSERT c.id IS UNIQUE;
CREATE CONSTRAINT ON (c:Category) 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 (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 (t:Tag) ASSERT t.id IS UNIQUE;
CREATE CONSTRAINT ON (p:Post) ASSERT p.slug 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 (c:Category) ASSERT c.slug IS UNIQUE;
CREATE CONSTRAINT ON (u:User) ASSERT u.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; CREATE CONSTRAINT ON (e:EmailAddress) ASSERT e.email IS UNIQUE;
' | cypher-shell ' | cypher-shell

View File

@ -49,34 +49,6 @@
</ds-number> </ds-number>
</ds-space> </ds-space>
</ds-flex-item> </ds-flex-item>
<ds-flex-item :width="{ base: '100%', sm: '50%', md: '33%' }">
<ds-space margin="small">
<ds-number
:count="0"
:label="$t('admin.dashboard.organizations')"
size="x-large"
uppercase
>
<client-only slot="count">
<hc-count-to :end-val="statistics.countOrganizations" />
</client-only>
</ds-number>
</ds-space>
</ds-flex-item>
<ds-flex-item :width="{ base: '100%', sm: '50%', md: '33%' }">
<ds-space margin="small">
<ds-number
:count="0"
:label="$t('admin.dashboard.projects')"
size="x-large"
uppercase
>
<client-only slot="count">
<hc-count-to :end-val="statistics.countProjects" />
</client-only>
</ds-number>
</ds-space>
</ds-flex-item>
<ds-flex-item :width="{ base: '100%', sm: '50%', md: '33%' }"> <ds-flex-item :width="{ base: '100%', sm: '50%', md: '33%' }">
<ds-space margin="small"> <ds-space margin="small">
<ds-number :count="0" :label="$t('admin.dashboard.invites')" size="x-large" uppercase> <ds-number :count="0" :label="$t('admin.dashboard.invites')" size="x-large" uppercase>
@ -137,8 +109,6 @@ export default {
countPosts countPosts
countComments countComments
countNotifications countNotifications
countOrganizations
countProjects
countInvites countInvites
countFollows countFollows
countShouts countShouts