<commit_before># Replaces the local database by the production one

USER=mes-aides-master
DATABASE=mes-aides-master

NOW=$(date +"%F-%H-%M-%S")

DISTANT_DUMP_FOLDER="~/dumps/dump-$NOW"
LOCAL_DUMP_FOLDER='./dump'


cd `dirname $0`

read -n 1 -p "Are you POSITIVE you want to replace ALL contents of the $DATABASE database with contents from the $USER one?  [y/N]" sure

if [[ $sure != 'y' ]]
then
    echo 'Cancelled'
    exit 1
fi

set -ex

ssh $USER@sg<EMAIL> "mongodump --db $DATABASE && mv dump $DISTANT_DUMP_FOLDER && gzip -rv $DISTANT_DUMP_FOLDER"
rm -rf $LOCAL_DUMP_FOLDER
scp -r <EMAIL>:$DISTANT_DUMP_FOLDER/$DATABASE $LOCAL_DUMP_FOLDER
gunzip -r $LOCAL_DUMP_FOLDER
mongorestore --drop --db $DATABASE $LOCAL_DUMP_FOLDER<commit_msg>Do not drop database contents on import<commit_after># Replaces the local database by the production one

USER=mes-aides-master
DATABASE=mes-aides-master

NOW=$(date +"%F-%H-%M-%S")

DISTANT_DUMP_FOLDER="~/dumps/dump-$NOW"
LOCAL_DUMP_FOLDER='./dump'


cd `dirname $0`

read -n 1 -p "Are you POSITIVE you want to merge contents of the local $DATABASE database with contents from the distant $USER one?  [y/N]" sure

if [[ $sure != 'y' ]]
then
    echo 'Cancelled'
    exit 1
fi

set -ex

ssh $USER@sg<EMAIL> "mongodump --db $DATABASE && mv dump $DISTANT_DUMP_FOLDER && gzip -rv $DISTANT_DUMP_FOLDER"
rm -rf $LOCAL_DUMP_FOLDER
scp -r <EMAIL>:$DISTANT_DUMP_FOLDER/$DATABASE $LOCAL_DUMP_FOLDER
gunzip -r $LOCAL_DUMP_FOLDER
mongorestore --db $DATABASE $LOCAL_DUMP_FOLDER
{'fraction_non_alphanumeric': 0.1264138389886893, 'fraction_numerical': 0.003992015968063872, 'mean_word_length': 4.718631178707224, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '755302', 'n_tokens_mistral': 636, 'n_tokens_neox': 609, 'n_words': 165}