diff --git a/backend/package.json b/backend/package.json index af148bc8c..1c74d3faa 100644 --- a/backend/package.json +++ b/backend/package.json @@ -42,7 +42,7 @@ ] }, "dependencies": { - "@hapi/joi": "^15.1.0", + "@hapi/joi": "^15.1.1", "activitystrea.ms": "~2.1.3", "apollo-cache-inmemory": "~1.6.3", "apollo-client": "~2.6.4", diff --git a/backend/src/middleware/handleHtmlContent/handleContentData.spec.js b/backend/src/middleware/handleHtmlContent/handleContentData.spec.js index 40d8a2481..fb088e428 100644 --- a/backend/src/middleware/handleHtmlContent/handleContentData.spec.js +++ b/backend/src/middleware/handleHtmlContent/handleContentData.spec.js @@ -198,7 +198,6 @@ describe('Hashtags', () => { Post(id: $id) { tags { id - name } } } @@ -234,10 +233,7 @@ describe('Hashtags', () => { }) it('both Hashtags are created with the "id" set to their "name"', async () => { - const expected = [ - { id: 'Democracy', name: 'Democracy' }, - { id: 'Liberty', name: 'Liberty' }, - ] + const expected = [{ id: 'Democracy' }, { id: 'Liberty' }] await expect( query({ query: postWithHastagsQuery, variables: postWithHastagsVariables }), ).resolves.toEqual( @@ -277,10 +273,7 @@ describe('Hashtags', () => { }, }) - const expected = [ - { id: 'Elections', name: 'Elections' }, - { id: 'Liberty', name: 'Liberty' }, - ] + const expected = [{ id: 'Elections' }, { id: 'Liberty' }] await expect( query({ query: postWithHastagsQuery, variables: postWithHastagsVariables }), ).resolves.toEqual( diff --git a/backend/src/schema/resolvers/users.js b/backend/src/schema/resolvers/users.js index 74561c5fe..4710942b6 100644 --- a/backend/src/schema/resolvers/users.js +++ b/backend/src/schema/resolvers/users.js @@ -151,7 +151,6 @@ export default { friendsCount: '<-[:FRIENDS]->(related:User)', followingCount: '-[:FOLLOWS]->(related:User)', followedByCount: '<-[:FOLLOWS]-(related:User)', - commentsCount: '-[:WROTE]->(r:Comment)', commentedCount: '-[:WROTE]->(:Comment)-[:COMMENTS]->(related:Post)', shoutedCount: '-[:SHOUTED]->(related:Post)', badgesCount: '<-[:REWARDED]-(related:Badge)', diff --git a/backend/src/schema/types/type/Post.gql b/backend/src/schema/types/type/Post.gql index 519af14ae..cbbcddfc9 100644 --- a/backend/src/schema/types/type/Post.gql +++ b/backend/src/schema/types/type/Post.gql @@ -29,11 +29,6 @@ type Post { categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT") comments: [Comment]! @relation(name: "COMMENTS", direction: "IN") - commentsCount: Int! - @cypher( - statement: "MATCH (this)<-[:COMMENTS]-(r:Comment) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(r)" - ) - shoutedBy: [User]! @relation(name: "SHOUTED", direction: "IN") shoutedCount: Int! @cypher( diff --git a/backend/src/schema/types/type/Tag.gql b/backend/src/schema/types/type/Tag.gql index 47021bf82..c9c36343a 100644 --- a/backend/src/schema/types/type/Tag.gql +++ b/backend/src/schema/types/type/Tag.gql @@ -1,6 +1,5 @@ type Tag { id: ID! - name: String! 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)") diff --git a/backend/src/schema/types/type/User.gql b/backend/src/schema/types/type/User.gql index e3e8f8450..46e699410 100644 --- a/backend/src/schema/types/type/User.gql +++ b/backend/src/schema/types/type/User.gql @@ -64,7 +64,6 @@ type User { ) comments: [Comment]! @relation(name: "WROTE", direction: "OUT") - commentsCount: Int! @cypher(statement: "MATCH (this)-[:WROTE]->(r:Comment) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(r)") commentedCount: Int! @cypher(statement: "MATCH (this)-[:WROTE]->(r:Comment)-[:COMMENTS]->(p:Post) WHERE NOT r.deleted = true AND NOT r.disabled = true AND NOT p.deleted = true AND NOT p.disabled = true RETURN COUNT(DISTINCT(p))") shouted: [Post]! @relation(name: "SHOUTED", direction: "OUT") @@ -143,7 +142,6 @@ type Query { followedByCount: Int followedByCurrentUser: Boolean contributionsCount: Int - commentsCount: Int commentedCount: Int shoutedCount: Int badgesCount: Int diff --git a/backend/src/seed/factories/tags.js b/backend/src/seed/factories/tags.js index 15ded1986..4a135e051 100644 --- a/backend/src/seed/factories/tags.js +++ b/backend/src/seed/factories/tags.js @@ -5,9 +5,9 @@ export default function(params) { return { mutation: ` - mutation($id: ID!, $name: String!) { - CreateTag(id: $id, name: $name) { - name + mutation($id: ID!) { + CreateTag(id: $id) { + id } } `, diff --git a/backend/yarn.lock b/backend/yarn.lock index 1ad799c18..186520186 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -768,31 +768,26 @@ resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.0.0.tgz#9f05469c88cb2fd3dcd624776b54ee95c312126a" integrity sha512-mV6T0IYqb0xL1UALPFplXYQmR0twnXG0M6jUswpquqT2sD12BOiCiLy3EvMp/Fy7s3DZElC4/aPjEjo2jeZpvw== -"@hapi/hoek@6.x.x": - version "6.2.4" - resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-6.2.4.tgz#4b95fbaccbfba90185690890bdf1a2fbbda10595" - integrity sha512-HOJ20Kc93DkDVvjwHyHawPwPkX44sIrbXazAUDiUXaY2R9JwQGo2PhFfnQtdrsIe4igjG2fPgMra7NYw7qhy0A== +"@hapi/bourne@1.x.x": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@hapi/bourne/-/bourne-1.3.2.tgz#0a7095adea067243ce3283e1b56b8a8f453b242a" + integrity sha512-1dVNHT76Uu5N3eJNTYcvxee+jzX4Z9lfciqRRHCU27ihbUcYi+iSc2iml5Ke1LXe1SyJCLA0+14Jh4tXJgOppA== "@hapi/hoek@8.x.x": version "8.0.1" resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-8.0.1.tgz#9712fa2ad124ac64668ab06ba847b1eaf83a03fd" integrity sha512-cctMYH5RLbElaUpZn3IJaUj9QNQD8iXDnl7xNY6KB1aFD2ciJrwpo3kvZowIT75uA+silJFDnSR2kGakALUymg== -"@hapi/joi@^15.0.3", "@hapi/joi@^15.1.0": - version "15.1.0" - resolved "https://registry.yarnpkg.com/@hapi/joi/-/joi-15.1.0.tgz#940cb749b5c55c26ab3b34ce362e82b6162c8e7a" - integrity sha512-n6kaRQO8S+kepUTbXL9O/UOL788Odqs38/VOfoCrATDtTvyfiO3fgjlSRaNkHabpTLgM7qru9ifqXlXbXk8SeQ== +"@hapi/joi@^15.0.3", "@hapi/joi@^15.1.0", "@hapi/joi@^15.1.1": + version "15.1.1" + resolved "https://registry.yarnpkg.com/@hapi/joi/-/joi-15.1.1.tgz#c675b8a71296f02833f8d6d243b34c57b8ce19d7" + integrity sha512-entf8ZMOK8sc+8YfeOlM8pCfg3b5+WZIKBfUaaJT8UsjAAPjartzxIYm3TIbjvA4u+u++KbcXD38k682nVHDAQ== dependencies: "@hapi/address" "2.x.x" - "@hapi/hoek" "6.x.x" - "@hapi/marker" "1.x.x" + "@hapi/bourne" "1.x.x" + "@hapi/hoek" "8.x.x" "@hapi/topo" "3.x.x" -"@hapi/marker@1.x.x": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@hapi/marker/-/marker-1.0.0.tgz#65b0b2b01d1be06304886ce9b4b77b1bfb21a769" - integrity sha512-JOfdekTXnJexfE8PyhZFyHvHjt81rBFSAbTIRAhF2vv/2Y1JzoKsGqxH/GpZJoF7aEfYok8JVcAHmSz1gkBieA== - "@hapi/topo@3.x.x": version "3.1.2" resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-3.1.2.tgz#57cc1317be1a8c5f47c124f9b0e3c49cd78424d2" diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index e1eab98c1..608f6468d 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -42,9 +42,9 @@ Given("we have a selection of tags and categories as well as posts", () => { slug: "health-wellbeing", icon: "medkit" }) - .create("Tag", { id: "t1", name: "Ecology" }) - .create("Tag", { id: "t2", name: "Nature" }) - .create("Tag", { id: "t3", name: "Democracy" }); + .create("Tag", { id: "Ecology" }) + .create("Tag", { id: "Nature" }) + .create("Tag", { id: "Democracy" }); const someAuthor = { id: "authorId", @@ -71,14 +71,14 @@ Given("we have a selection of tags and categories as well as posts", () => { .relate("Post", "Categories", { from: "p0", to: "cat1" }) .relate("Post", "Categories", { from: "p1", to: "cat2" }) .relate("Post", "Categories", { from: "p2", to: "cat1" }) - .relate("Post", "Tags", { from: "p0", to: "t1" }) - .relate("Post", "Tags", { from: "p0", to: "t2" }) - .relate("Post", "Tags", { from: "p0", to: "t3" }) - .relate("Post", "Tags", { from: "p1", to: "t2" }) - .relate("Post", "Tags", { from: "p1", to: "t3" }) - .relate("Post", "Tags", { from: "p2", to: "t2" }) - .relate("Post", "Tags", { from: "p2", to: "t3" }) - .relate("Post", "Tags", { from: "p3", to: "t3" }); + .relate("Post", "Tags", { from: "p0", to: "Ecology" }) + .relate("Post", "Tags", { from: "p0", to: "Nature" }) + .relate("Post", "Tags", { from: "p0", to: "Democracy" }) + .relate("Post", "Tags", { from: "p1", to: "Nature" }) + .relate("Post", "Tags", { from: "p1", to: "Democracy" }) + .relate("Post", "Tags", { from: "p2", to: "Nature" }) + .relate("Post", "Tags", { from: "p2", to: "Democracy" }) + .relate("Post", "Tags", { from: "p3", to: "Democracy" }); }); Given("we have the following user accounts:", table => { @@ -260,7 +260,7 @@ Then("the first post on the landing page has the title:", title => { Then( "the page {string} returns a 404 error with a message:", (route, message) => { - // TODO: how can we check HTTP codes with cypress? + cy.request({ url: route, failOnStatusCode: false }).its('status').should('eq', 404) cy.visit(route, { failOnStatusCode: false }); cy.get(".error").should("contain", message); } diff --git a/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh b/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh index 8d16f42fa..f80ea8b8b 100755 --- a/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh +++ b/deployment/legacy-migration/maintenance-worker/migration/mongo/export.sh @@ -38,14 +38,12 @@ export_collection "emotions" export_collection_query "follows" "{'foreignService': 'organizations'}" "organizations" export_collection_query "follows" "{'foreignService': 'users'}" "users" export_collection "invites" -export_collection "notifications" export_collection "organizations" export_collection "pages" export_collection "projects" export_collection "settings" export_collection "shouts" export_collection "status" -export_collection "systemnotifications" export_collection "users" export_collection "userscandos" export_collection "usersettings" diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/contributions.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/contributions.cql index a0f1418aa..af81528f2 100644 --- a/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/contributions.cql +++ b/deployment/legacy-migration/maintenance-worker/migration/neo4j/contributions/contributions.cql @@ -148,6 +148,6 @@ MATCH (c:Category {id: categoryId}) MERGE (p)-[:CATEGORIZED]->(c) WITH p, post.tags AS tags UNWIND tags AS tag -MERGE (t:Tag {id: tag, name: tag}) +MERGE (t:Tag {id: apoc.text.clean(tag), disabled: false, deleted: false}) MERGE (p)-[:TAGGED]->(t) ; diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/users/delete.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/users/delete.cql index 23935b3e0..32679f6c8 100644 --- a/deployment/legacy-migration/maintenance-worker/migration/neo4j/users/delete.cql +++ b/deployment/legacy-migration/maintenance-worker/migration/neo4j/users/delete.cql @@ -1 +1,2 @@ -MATCH (n:User) DETACH DELETE n; \ No newline at end of file +MATCH (n:User) DETACH DELETE n; +MATCH (e:EmailAddress) DETACH DELETE e; diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/users/users.cql b/deployment/legacy-migration/maintenance-worker/migration/neo4j/users/users.cql index a1045bdeb..02dff089f 100644 --- a/deployment/legacy-migration/maintenance-worker/migration/neo4j/users/users.cql +++ b/deployment/legacy-migration/maintenance-worker/migration/neo4j/users/users.cql @@ -94,12 +94,11 @@ } } */ - CALL apoc.load.json("file:${IMPORT_CHUNK_PATH_CQL_FILE}") YIELD value as user MERGE(u:User {id: user._id["$oid"]}) ON CREATE SET u.name = user.name, -u.slug = user.slug, +u.slug = COALESCE(user.slug, apoc.text.random(20, "[A-Za-z]")), u.email = user.email, u.encryptedPassword = user.password, u.avatar = replace(user.avatar, 'https://api-alpha.human-connection.org', ''), diff --git a/neo4j/db_setup.sh b/neo4j/db_setup.sh index d4c7b9af8..51276cf39 100755 --- a/neo4j/db_setup.sh +++ b/neo4j/db_setup.sh @@ -29,7 +29,6 @@ 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; diff --git a/webapp/components/Comment.vue b/webapp/components/Comment.vue index 9096fb6e8..c53d0a231 100644 --- a/webapp/components/Comment.vue +++ b/webapp/components/Comment.vue @@ -67,7 +67,7 @@ import { mapGetters, mapMutations } from 'vuex' import HcUser from '~/components/User' import ContentMenu from '~/components/ContentMenu' import ContentViewer from '~/components/Editor/ContentViewer' -import HcEditCommentForm from '~/components/comments/EditCommentForm/EditCommentForm' +import HcEditCommentForm from '~/components/EditCommentForm/EditCommentForm' export default { data: function() { diff --git a/webapp/components/comments/CommentForm/spec.js b/webapp/components/CommentForm/CommentForm.spec.js similarity index 98% rename from webapp/components/comments/CommentForm/spec.js rename to webapp/components/CommentForm/CommentForm.spec.js index 2d212c91d..5e7c952af 100644 --- a/webapp/components/comments/CommentForm/spec.js +++ b/webapp/components/CommentForm/CommentForm.spec.js @@ -1,5 +1,5 @@ import { mount, createLocalVue } from '@vue/test-utils' -import CommentForm from './index.vue' +import CommentForm from './CommentForm' import Styleguide from '@human-connection/styleguide' import Vuex from 'vuex' import MutationObserver from 'mutation-observer' diff --git a/webapp/components/comments/CommentForm/index.vue b/webapp/components/CommentForm/CommentForm.vue similarity index 84% rename from webapp/components/comments/CommentForm/index.vue rename to webapp/components/CommentForm/CommentForm.vue index e0e0058e5..795727578 100644 --- a/webapp/components/comments/CommentForm/index.vue +++ b/webapp/components/CommentForm/CommentForm.vue @@ -24,10 +24,10 @@ diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index dca23a882..9d1c92cc9 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -244,9 +244,8 @@ export default { query() { return gql` { - Tag(orderBy: name_asc) { + Tag(orderBy: id_asc) { id - name } } ` diff --git a/webapp/components/CountTo.vue b/webapp/components/CountTo.vue index ee0e3e082..3210944c8 100644 --- a/webapp/components/CountTo.vue +++ b/webapp/components/CountTo.vue @@ -2,7 +2,7 @@ { - this.isReady = true - }, 500) - }, } diff --git a/webapp/components/DeleteData/DeleteData.spec.js b/webapp/components/DeleteData/DeleteData.spec.js index 139316ed2..73ca985fa 100644 --- a/webapp/components/DeleteData/DeleteData.spec.js +++ b/webapp/components/DeleteData/DeleteData.spec.js @@ -48,7 +48,7 @@ describe('DeleteData.vue', () => { } getters = { 'auth/user': () => { - return { id: 'u343', name: deleteAccountName, contributionsCount: 2, commentsCount: 3 } + return { id: 'u343', name: deleteAccountName, contributionsCount: 2, commentedCount: 3 } }, } actions = { 'auth/logout': jest.fn() } diff --git a/webapp/components/DeleteData/DeleteData.vue b/webapp/components/DeleteData/DeleteData.vue index 293e65221..f6e6d47f0 100644 --- a/webapp/components/DeleteData/DeleteData.vue +++ b/webapp/components/DeleteData/DeleteData.vue @@ -30,12 +30,12 @@ }} - @@ -44,7 +44,7 @@ uppercase > - + @@ -58,7 +58,7 @@ uppercase > - + @@ -72,7 +72,7 @@ uppercase > - + @@ -81,7 +81,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -99,7 +99,7 @@ - + @@ -128,9 +128,6 @@ export default { return process.client }, }, - mounted() { - this.$apollo.queries.statistics.startPolling(5000) - }, apollo: { statistics: { query: gql` diff --git a/webapp/pages/admin/tags.vue b/webapp/pages/admin/tags.vue index c5a28dc11..9ede1d502 100644 --- a/webapp/pages/admin/tags.vue +++ b/webapp/pages/admin/tags.vue @@ -1,12 +1,12 @@