Merge pull request #5635 from FinnStutzenstein/dsHelperTools

Helper-tools for the DataStore
This commit is contained in:
Finn Stutzenstein 2020-10-23 08:32:03 +02:00 committed by GitHub
commit 399bf389d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 58 additions and 6 deletions

View File

@ -1,2 +1,3 @@
#!/bin/bash #!/bin/bash
cd "$(dirname $0)"
docker-compose -f docker-compose.yml -f docker-compose.dev.yml $@ docker-compose -f docker-compose.yml -f docker-compose.dev.yml $@

5
dev-commands/clear-ds.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
set -e
curl --header "Content-Type: application/json" -d '' http://localhost:9011/internal/datastore/writer/truncate_db

8
dev-commands/export-ds.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
set -e
cd "$(dirname $0)"
TARGET=${1:-export.json}
URL="http://localhost:9010/internal/datastore/reader/get_everything"
curl --header "Content-Type: application/json" -d '{}' $URL 2> /dev/null | python3 strip-meta-fields.py > $TARGET

10
dev-commands/set-ds.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
set -e
cd "$(dirname $0)"
# first argument is the example data
DATA=$(cat ${1:-../docs/example-data.json})
./clear-ds.sh
docker-compose -f ../docker-compose.yml -f ../docker-compose.dev.yml exec datastore-writer \
bash -c "source export-database-variables.sh; echo '$DATA' > /data.json; export DATASTORE_INITIAL_DATA_FILE=/data.json; python cli/create_initial_data.py"

View File

@ -0,0 +1,12 @@
import sys
import json
data = sys.stdin.read()
json_data = json.loads(data)
for collection, models in json_data.items():
for model in models:
for field in list(model.keys()):
if field.startswith("meta_"):
del model[field]
sys.stdout.write(json.dumps(json_data, separators=(',', ':')))

View File

@ -5,12 +5,18 @@ services:
volumes: volumes:
- ./openslides-datastore-service/shared/shared:/app/shared - ./openslides-datastore-service/shared/shared:/app/shared
- ./openslides-datastore-service/reader/reader:/app/reader - ./openslides-datastore-service/reader/reader:/app/reader
ports:
- "9010:9010"
environment:
- DATASTORE_ENABLE_DEV_ENVIRONMENT=1
datastore-writer: datastore-writer:
image: openslides-datastore-writer-dev image: openslides-datastore-writer-dev
volumes: volumes:
- ./openslides-datastore-service/shared/shared:/app/shared - ./openslides-datastore-service/shared/shared:/app/shared
- ./openslides-datastore-service/writer/writer:/app/writer - ./openslides-datastore-service/writer/writer:/app/writer
- ./openslides-datastore-service/cli:/app/cli - ./openslides-datastore-service/cli:/app/cli
ports:
- "9011:9011"
environment: environment:
- DATASTORE_ENABLE_DEV_ENVIRONMENT=1 - DATASTORE_ENABLE_DEV_ENVIRONMENT=1
- COMMAND=create_initial_data - COMMAND=create_initial_data

View File

@ -203,6 +203,16 @@ Interface GetManyRequest {
*/ */
get_all(collection: Collection, mapped_fields?: Field[], get_deleted_models?: DeletedModelsBehaviour): Map<Id, Partial<Model>>; get_all(collection: Collection, mapped_fields?: Field[], get_deleted_models?: DeletedModelsBehaviour): Map<Id, Partial<Model>>;
/**
* Returns all models.
* Url: POST to /internal/datastore/reader/get_everything
*
* This is a dev route only!
*
* @returns The example data format: A mapping of a collection to a list of models.
*/
get_everything(get_deleted_models?: DeletedModelsBehaviour): Map<Collection, Model[]>;
/** /**
* Returns all models of one collection that satisfy the filter condition. * Returns all models of one collection that satisfy the filter condition.
* Url: POST to /internal/datastore/reader/filter * Url: POST to /internal/datastore/reader/filter

@ -1 +1 @@
Subproject commit e400ea34ad3750d22ea3f3a7130df3492fabf306 Subproject commit 655cbd4bd8397ff4a0665c549283e6e71e5ea123

@ -1 +1 @@
Subproject commit 4af78b8ae851c0aa33e48df573b821f29275eb87 Subproject commit e22160c0b953fbbe01eb1e79c72bdf0701d5e288

@ -1 +1 @@
Subproject commit 4dc025e3c5bfd4bed056b583769ed8a2390ea730 Subproject commit 32b809bc2d6a046b267e01fb2dd641d9eff64093

@ -1 +1 @@
Subproject commit 418f7c3dc9fb1b9fe20de66f99070cb1389a07ad Subproject commit cde0f50e56028b0724cc6139b0caaa4bd045bb89

@ -1 +1 @@
Subproject commit 95a5347dea08b5dcda7f72718c614816ddca1020 Subproject commit 8d3c7b05b56051b6291ef6e324f04ac65a3d6a0e

@ -1 +1 @@
Subproject commit 27eea2f87e8f1f241bdd78e1493f5eb33e49e54e Subproject commit cdf1b72b2252d1179d8e4a548f23b8df31e33c4c