diff --git a/scripts/insert_data.sh b/scripts/insert_data.sh index 6e4f79b26d502b0081a2ccf63ac0e4abdd323887..26e3b1a57aac24fc897756f744cb888769f5c936 100755 --- a/scripts/insert_data.sh +++ b/scripts/insert_data.sh @@ -7,20 +7,33 @@ # - Filter: An array of n values, that will create n indexes in ElasticSearch, each one filtering data from Portal Transparencia using its corresponding string. Ex: "UNIVERSIDADE FEDERAL DO PARANA" # - University: An array of n values, with n being the same n as Filter's array. This array should contain the initials from Universities declared in Filter array, in the same order. -if [ "$#" -ne 4 ]; then - echo "Usage: $0 <year> <month> <user> <password>" - echo "Example: $0 2016 12 myuser mypass" +if [[ "$#" -ne 5 || "$1" == "-help" || "$1" == "--help" ]]; then + echo " Usage: $0 <year> <month> <user> <password> <insertions>" + echo " Insertions must be one between: expenses, travel_allowances, workers, ministry_of_health, all" + echo " Example: $0 2016 12 myuser mypass all" exit fi -# First, insert Expenses data. -(cd expenses && ./insert_expenses.sh $1 $2 $3 $4) +if [[ "$5" == "all" || "$5" == "expenses" ]]; then + # First, insert Expenses data. + echo "Inserting Expenses from ${1}-${2}..." + (cd expenses && ./insert_expenses.sh $1 $2 $3 $4) +fi -# We should now insert Travel allowance data. -(cd travel_allowances && ./insert_travel_allowances.sh $1 $2 $3 $4) +if [[ "$5" == "all" || "$5" == "travel_allowances" ]]; then + # We should now insert Travel allowance data. + echo "Inserting Travel Allowances from ${1}-${2}..." + (cd travel_allowances && ./insert_travel_allowances.sh $1 $2 $3 $4) +fi -# Now, insert Workers data. -(cd workers && ./insert_register_payment.sh $1 $2 $3 $4) +if [[ "$5" == "all" || "$5" == "workers" ]]; then + # Now, insert Workers data. + echo "Inserting Workers from ${1}-${2}..." + (cd workers && ./insert_register_payment.sh $1 $2 $3 $4) +fi -# Last but not least, insert data from Health Ministry. -(cd ministry_of_health && ./insert_ministry_of_health.sh $1 $2 $3 $4) +if [[ "$5" == "all" || "$5" == "ministry_of_health" ]]; then + # Last but not least, insert data from Health Ministry. + echo "Inserting data from Ministry Of Health from ${1}-${2}..." + (cd ministry_of_health && ./insert_ministry_of_health.sh $1 $2 $3 $4) +fi