diff --git a/.env b/scripts/navitia/.env similarity index 100% rename from .env rename to scripts/navitia/.env diff --git a/calcul_duration_for_routes.bm.sh b/scripts/navitia/calcul_duration_for_routes.bm.sh similarity index 100% rename from calcul_duration_for_routes.bm.sh rename to scripts/navitia/calcul_duration_for_routes.bm.sh diff --git a/calcul_duration_for_routes.sh b/scripts/navitia/calcul_duration_for_routes.sh similarity index 100% rename from calcul_duration_for_routes.sh rename to scripts/navitia/calcul_duration_for_routes.sh diff --git a/get_public_transports_from_France.bm.sh b/scripts/navitia/get_public_transports_from_France.bm.sh similarity index 96% rename from get_public_transports_from_France.bm.sh rename to scripts/navitia/get_public_transports_from_France.bm.sh index 95711849e..c6122013f 100755 --- a/get_public_transports_from_France.bm.sh +++ b/scripts/navitia/get_public_transports_from_France.bm.sh @@ -180,6 +180,12 @@ echo $(date +"%Y-%m-%d-%H-%M-%S") >> $LOG_FILE # Execute all SQL commands in one go echo "Sql file length : $(wc -l < "$SQL_FILE") lines." >> $LOG_FILE -psql -q < /tmp/sql_commands.sql -echo "Inserts done." >> $LOG_FILE +if [ -s $SQL_FILE ]; then + psql -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" + psql -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" + psql -q < $SQL_FILE + echo "Inserts done." >> $LOG_FILE +else + echo "SQL file empty, aborting" >> $LOG_FILE +fi diff --git a/get_public_transports_from_France.sh b/scripts/navitia/get_public_transports_from_France.sh similarity index 94% rename from get_public_transports_from_France.sh rename to scripts/navitia/get_public_transports_from_France.sh index 0463737d3..ad6da2dc6 100755 --- a/get_public_transports_from_France.sh +++ b/scripts/navitia/get_public_transports_from_France.sh @@ -201,6 +201,11 @@ echo $(date +"%Y-%m-%d-%H-%M-%S") >> $LOG_FILE # Execute all SQL commands in one go echo "Sql file length : $(wc -l < "$SQL_FILE") lines." >> $LOG_FILE -$CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -q -U $DB_USER -d $DB_NAME < /tmp/sql_commands.sql - -echo "Inserts done." >> $LOG_FILE +if [ -s $SQL_FILE ]; then + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -q -U $DB_USER -d $DB_NAME < /tmp/sql_commands.sql + echo "Inserts done." >> $LOG_FILE +else + echo "SQL file empty, aborting" >> $LOG_FILE +fi diff --git a/get_public_transports_from_France_distinct.bm.sh b/scripts/navitia/get_public_transports_from_France_distinct.bm.sh similarity index 97% rename from get_public_transports_from_France_distinct.bm.sh rename to scripts/navitia/get_public_transports_from_France_distinct.bm.sh index 8a81e788d..82f8049af 100755 --- a/get_public_transports_from_France_distinct.bm.sh +++ b/scripts/navitia/get_public_transports_from_France_distinct.bm.sh @@ -53,12 +53,6 @@ echo "Total waypoints fetched: $nb_waypoints" # Initialize SQL file > "$SQL_FILE" -psql -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" -psql -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" - - - - for ((k=1; k<=nb_waypoints; k++)); do # Log progress every 10 waypoints if (( k % 10 == 0 )) || (( k == 1 )); then @@ -222,6 +216,13 @@ echo $(date +"%Y-%m-%d-%H-%M-%S") >> $LOG_FILE # Execute all SQL commands in one go echo "Sql file length : $(wc -l < "$SQL_FILE") lines." >> $LOG_FILE -psql -q < /tmp/sql_commands.sql -echo "Inserts done." >> $LOG_FILE +if [ -s $SQL_FILE ]; then + psql -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" + psql -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" + psql -q < $SQL_FILE + echo "Inserts done." >> $LOG_FILE +else + echo "SQL file empty, aborting" >> $LOG_FILE +fi + diff --git a/get_public_transports_from_France_distinct.sh b/scripts/navitia/get_public_transports_from_France_distinct.sh similarity index 95% rename from get_public_transports_from_France_distinct.sh rename to scripts/navitia/get_public_transports_from_France_distinct.sh index 334c36a0e..de535fb5b 100755 --- a/get_public_transports_from_France_distinct.sh +++ b/scripts/navitia/get_public_transports_from_France_distinct.sh @@ -74,12 +74,6 @@ echo "Total waypoints fetched: $nb_waypoints" # Initialize SQL file > "$SQL_FILE" -$CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" -$CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" - - - - for ((k=1; k<=nb_waypoints; k++)); do # Log progress every 10 waypoints if (( k % 10 == 0 )) || (( k == 1 )); then @@ -243,6 +237,13 @@ echo $(date +"%Y-%m-%d-%H-%M-%S") >> $LOG_FILE # Execute all SQL commands in one go echo "Sql file length : $(wc -l < "$SQL_FILE") lines." >> $LOG_FILE -$CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -q -U $DB_USER -d $DB_NAME < /tmp/sql_commands.sql -echo "Inserts done." >> $LOG_FILE +if [ -s $SQL_FILE ]; then + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -q -U $DB_USER -d $DB_NAME < /tmp/sql_commands.sql + echo "Inserts done." >> $LOG_FILE +else + echo "SQL file empty, aborting" >> $LOG_FILE +fi + diff --git a/get_public_transports_from_Isere.bm.sh b/scripts/navitia/get_public_transports_from_Isere.bm.sh similarity index 96% rename from get_public_transports_from_Isere.bm.sh rename to scripts/navitia/get_public_transports_from_Isere.bm.sh index 3824d514e..92e067005 100755 --- a/get_public_transports_from_Isere.bm.sh +++ b/scripts/navitia/get_public_transports_from_Isere.bm.sh @@ -180,6 +180,12 @@ echo $(date +"%Y-%m-%d-%H-%M-%S") >> $LOG_FILE # Execute all SQL commands in one go echo "Sql file length : $(wc -l < "$SQL_FILE") lines." >> $LOG_FILE -psql -q < /tmp/sql_commands.sql -echo "Inserts done." >> $LOG_FILE +if [ -s $SQL_FILE ]; then + psql -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" + psql -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" + psql -q < $SQL_FILE + echo "Inserts done." >> $LOG_FILE +else + echo "SQL file empty, aborting" >> $LOG_FILE +fi diff --git a/get_public_transports_from_Isere.sh b/scripts/navitia/get_public_transports_from_Isere.sh similarity index 93% rename from get_public_transports_from_Isere.sh rename to scripts/navitia/get_public_transports_from_Isere.sh index 6bd33b441..985ab7f63 100755 --- a/get_public_transports_from_Isere.sh +++ b/scripts/navitia/get_public_transports_from_Isere.sh @@ -71,12 +71,6 @@ echo "Total waypoints fetched: $nb_waypoints" # Initialize SQL file > "$SQL_FILE" -$CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" -$CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" - - - - for ((k=1; k<=nb_waypoints; k++)); do # Log progress every 10 waypoints if (( k % 10 == 0 )) || (( k == 1 )); then @@ -201,6 +195,12 @@ echo $(date +"%Y-%m-%d-%H-%M-%S") >> $LOG_FILE # Execute all SQL commands in one go echo "Sql file length : $(wc -l < "$SQL_FILE") lines." >> $LOG_FILE -$CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -q -U $DB_USER -d $DB_NAME < /tmp/sql_commands.sql -echo "Inserts done." >> $LOG_FILE +if [ -s $SQL_FILE ]; then + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -q -U $DB_USER -d $DB_NAME < /tmp/sql_commands.sql + echo "Inserts done." >> $LOG_FILE +else + echo "SQL file empty, aborting" >> $LOG_FILE +fi diff --git a/get_public_transports_from_Isere_distinct.sh b/scripts/navitia/get_public_transports_from_Isere_distinct.sh similarity index 95% rename from get_public_transports_from_Isere_distinct.sh rename to scripts/navitia/get_public_transports_from_Isere_distinct.sh index 0d7d462f4..4f63123d8 100755 --- a/get_public_transports_from_Isere_distinct.sh +++ b/scripts/navitia/get_public_transports_from_Isere_distinct.sh @@ -74,12 +74,6 @@ echo "Total waypoints fetched: $nb_waypoints" # Initialize SQL file > "$SQL_FILE" -$CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" -$CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" - - - - for ((k=1; k<=nb_waypoints; k++)); do # Log progress every 10 waypoints if (( k % 10 == 0 )) || (( k == 1 )); then @@ -243,6 +237,12 @@ echo $(date +"%Y-%m-%d-%H-%M-%S") >> $LOG_FILE # Execute all SQL commands in one go echo "Sql file length : $(wc -l < "$SQL_FILE") lines." >> $LOG_FILE -$CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -q -U $DB_USER -d $DB_NAME < /tmp/sql_commands.sql -echo "Inserts done." >> $LOG_FILE +if [ -s $SQL_FILE ]; then + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -q -U $DB_USER -d $DB_NAME < /tmp/sql_commands.sql + echo "Inserts done." >> $LOG_FILE +else + echo "SQL file empty, aborting" >> $LOG_FILE +fi diff --git a/get_public_transports_from_Rhone.bm.sh b/scripts/navitia/get_public_transports_from_Rhone.bm.sh similarity index 96% rename from get_public_transports_from_Rhone.bm.sh rename to scripts/navitia/get_public_transports_from_Rhone.bm.sh index 5b398a2c6..654891dd8 100755 --- a/get_public_transports_from_Rhone.bm.sh +++ b/scripts/navitia/get_public_transports_from_Rhone.bm.sh @@ -50,12 +50,6 @@ echo "Total waypoints fetched: $nb_waypoints" # Initialize SQL file > "$SQL_FILE" -psql -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" -psql -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" - - - - for ((k=1; k<=nb_waypoints; k++)); do # Log progress every 10 waypoints if (( k % 10 == 0 )) || (( k == 1 )); then @@ -180,6 +174,12 @@ echo $(date +"%Y-%m-%d-%H-%M-%S") >> $LOG_FILE # Execute all SQL commands in one go echo "Sql file length : $(wc -l < "$SQL_FILE") lines." >> $LOG_FILE -psql -q < /tmp/sql_commands.sql -echo "Inserts done." >> $LOG_FILE +if [ -s $SQL_FILE ]; then + psql -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" + psql -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" + psql -q < $SQL_FILE + echo "Inserts done." >> $LOG_FILE +else + echo "SQL file empty, aborting" >> $LOG_FILE +fi diff --git a/get_public_transports_from_Rhone.sh b/scripts/navitia/get_public_transports_from_Rhone.sh similarity index 93% rename from get_public_transports_from_Rhone.sh rename to scripts/navitia/get_public_transports_from_Rhone.sh index 1a59a1397..372581300 100755 --- a/get_public_transports_from_Rhone.sh +++ b/scripts/navitia/get_public_transports_from_Rhone.sh @@ -70,12 +70,6 @@ echo "Total waypoints fetched: $nb_waypoints" # Initialize SQL file > "$SQL_FILE" -$CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" -$CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" - - - - for ((k=1; k<=nb_waypoints; k++)); do # Log progress every 10 waypoints if (( k % 10 == 0 )) || (( k == 1 )); then @@ -200,6 +194,12 @@ echo $(date +"%Y-%m-%d-%H-%M-%S") >> $LOG_FILE # Execute all SQL commands in one go echo "Sql file length : $(wc -l < "$SQL_FILE") lines." >> $LOG_FILE -$CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -q -U $DB_USER -d $DB_NAME < /tmp/sql_commands.sql -echo "Inserts done." >> $LOG_FILE +if [ -s $SQL_FILE ]; then + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.waypoints_stopareas RESTART IDENTITY;" + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -U $DB_USER -d $DB_NAME -t -c "TRUNCATE TABLE guidebook.stopareas RESTART IDENTITY;" + $CCOMPOSE -p "${PROJECT_NAME}" exec -T $SERVICE_NAME psql -q -U $DB_USER -d $DB_NAME < /tmp/sql_commands.sql + echo "Inserts done." >> $LOG_FILE +else + echo "SQL file empty, aborting" >> $LOG_FILE +fi