diff --git a/backend/add_teaser_image_heights.sh b/backend/add_teaser_image_heights.sh new file mode 100755 index 000000000..154ccdafb --- /dev/null +++ b/backend/add_teaser_image_heights.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +shopt -s nullglob +TEMP_FILE=/var/lib/neo4j/import/temp.json +for image in public/uploads/*; do + [ -e "$image" ] || continue + export IMAGE_METADATA=$( identify -format '%w %h' "$image" ) + JSON_STRING=$( jq -n \ + --arg imageURL "$image" \ + --arg imageMetaData "$IMAGE_METADATA" \ + '{imageURL: $imageURL, imageMetaData: $imageMetaData}' ) + echo "$JSON_STRING," >> "$TEMP_FILE" +done + +ENV_FILE=$(dirname "$0")/.env +[[ -f "$ENV_FILE" ]] && source "$ENV_FILE" + +if [ -z "$NEO4J_USERNAME" ] || [ -z "$NEO4J_PASSWORD" ]; then + echo "Please set NEO4J_USERNAME and NEO4J_PASSWORD environment variables." + echo "Database manipulation is not possible without connecting to the database." + echo "E.g. you could \`cp .env.template .env\` unless you run the script in a docker container" +fi + +until echo 'RETURN "Connection successful" as info;' | cypher-shell +do + echo "Connecting to neo4j failed, trying again..." + sleep 1 +done +echo " +WITH "file:${TEMP_FILE}" +AS url +CALL apoc.load.json(url) YIELD value as post +MATCH (p:Post {image: post.imageURL}) return p; +" | cypher-shell diff --git a/backend/src/schema/resolvers/posts.js b/backend/src/schema/resolvers/posts.js index ee6a82d42..c7c4abdca 100644 --- a/backend/src/schema/resolvers/posts.js +++ b/backend/src/schema/resolvers/posts.js @@ -297,7 +297,7 @@ export default { }, Post: { ...Resolver('Post', { - undefinedToNull: ['activityId', 'objectId', 'image', 'language', 'pinnedAt', 'pinned'], + undefinedToNull: ['activityId', 'objectId', 'image', 'language', 'pinnedAt', 'pinned', 'teaserImageHeight'], hasMany: { tags: '-[:TAGGED]->(related:Tag)', categories: '-[:CATEGORIZED]->(related:Category)', diff --git a/backend/src/schema/types/type/Post.gql b/backend/src/schema/types/type/Post.gql index a52558071..fd8955db8 100644 --- a/backend/src/schema/types/type/Post.gql +++ b/backend/src/schema/types/type/Post.gql @@ -118,6 +118,7 @@ type Post { contentExcerpt: String image: String imageUpload: Upload + teaserImageHeight: String visibility: Visibility deleted: Boolean disabled: Boolean @@ -194,6 +195,7 @@ type Mutation { visibility: Visibility language: String categoryIds: [ID] + teaserImageHeight: String ): Post DeletePost(id: ID!): Post AddPostEmotions(to: _PostInput!, data: _EMOTEDInput!): EMOTED diff --git a/deployment/legacy-migration/maintenance-worker/migration/mongo/.env b/deployment/legacy-migration/maintenance-worker/migration/mongo/.env index 376cb56d0..e1f0bcdcf 100644 --- a/deployment/legacy-migration/maintenance-worker/migration/mongo/.env +++ b/deployment/legacy-migration/maintenance-worker/migration/mongo/.env @@ -12,6 +12,6 @@ # On Windows this resolves to C:\Users\dornhoeschen\AppData\Local\Temp\mongo-export (MinGW) EXPORT_PATH='/tmp/mongo-export/' EXPORT_MONGOEXPORT_BIN='mongoexport' -MONGO_EXPORT_SPLIT_SIZE=6000 +MONGO_EXPORT_SPLIT_SIZE=500000 # On Windows use something like this # EXPORT_MONGOEXPORT_BIN='C:\Program Files\MongoDB\Server\3.6\bin\mongoexport.exe' diff --git a/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh b/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh index ccb22dafb..bdb27a5f2 100755 --- a/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh +++ b/deployment/legacy-migration/maintenance-worker/migration/neo4j/import.sh @@ -39,6 +39,7 @@ function import_collection () { echo "Import $1 ${CHUNK_FILE_NAME} (${chunk})" echo "${NEO4J_COMMAND}" | "${IMPORT_CYPHERSHELL_BIN}" > /dev/null # add file to array and file + echo "$IMPORT_CHUNK_PATH_CQL_FILE" IMPORT_INDEX+=("${CHUNK_FILE_NAME}") echo "${CHUNK_FILE_NAME}" >> ${INDEX_FILE} else diff --git a/neo4j/add_teaser_image_heights.sh b/neo4j/add_teaser_image_heights.sh new file mode 100644 index 000000000..890492ddc --- /dev/null +++ b/neo4j/add_teaser_image_heights.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -e + +echo "images" +shopt -s nullglob +for image in *; do +# [ -e "$image" ] || continue + echo "$image" +done + +# ENV_FILE=$(dirname "$0")/.env +# [[ -f "$ENV_FILE" ]] && source "$ENV_FILE" + +# if [ -z "$NEO4J_USERNAME" ] || [ -z "$NEO4J_PASSWORD" ]; then +# echo "Please set NEO4J_USERNAME and NEO4J_PASSWORD environment variables." +# echo "Database manipulation is not possible without connecting to the database." +# echo "E.g. you could \`cp .env.template .env\` unless you run the script in a docker container" +# fi + +# until echo 'RETURN "Connection successful" as info;' | cypher-shell +# do +# echo "Connecting to neo4j failed, trying again..." +# sleep 1 +# done + +# echo " +# MATCH (post:Post) where post.teaserImageHeight is not null return post; +# " | cypher-shell \ No newline at end of file diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index 734e3be81..8b55772e3 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -7,7 +7,7 @@ @submit="submit" >