From 178d7972ea884339dea818e22776d8186e068161 Mon Sep 17 00:00:00 2001 From: ChuufMaster Date: Fri, 18 Oct 2024 04:04:52 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20Fixed=20some=20prob?= =?UTF-8?q?lems=20with=20the=20auto=20import=20script=20not=20using=20the?= =?UTF-8?q?=20correct=20csv=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/update_birds.yml | 3 +++ scripts/bash/auto_import.sh | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/update_birds.yml b/.github/workflows/update_birds.yml index bf5a0ad8..555f9d73 100644 --- a/.github/workflows/update_birds.yml +++ b/.github/workflows/update_birds.yml @@ -5,6 +5,9 @@ on: - cron: "0 8 * * *" workflow_dispatch: workflow_call: + push: + branches: + - dev/fix/auto_import jobs: update_data: diff --git a/scripts/bash/auto_import.sh b/scripts/bash/auto_import.sh index 038a4837..a7cc6009 100755 --- a/scripts/bash/auto_import.sh +++ b/scripts/bash/auto_import.sh @@ -17,6 +17,7 @@ else fi BIRDS=birds.csv +IS_TEST=false if [[ -z "$3" ]]; then echo "Getting birds" curl -L -o birds.csv "https://api.birdmap.africa/sabap2/v2/coverage/country/southafrica/species?format=csv" @@ -45,14 +46,14 @@ do echo "Downloading ${line} CSV" if curl -L "$FULL_URL" -o ${line}.csv ; then - if [[ IS_TEST ]]; then - awk '{FS=","} {print } NR==10{exit}' ${line}.csv > ${line}_short.csv - cat ${line}_short.csv - fi - curl -X 'POST' \ - "$URL/api/Import/import?province=${line}" \ - -H 'accept: */*' \ - -H 'Content-Type: multipart/form-data' \ - -F "file=@${line}_short.csv;type=text/csv" + if [[ -z $IS_TEST ]]; then + awk '{FS=","} {print } NR==10{exit}' ${line}.csv > ${line}_short.csv + cat ${line}_short.csv + fi + curl -X 'POST' \ + "$URL/api/Import/import?province=${line}" \ + -H 'accept: */*' \ + -H 'Content-Type: multipart/form-data' \ + -F "file=@${line}.csv;type=text/csv" fi done < "$PROVINCE_LIST" From 8da44e5b5b705cc213e8f6b64142feb8105cbb2e Mon Sep 17 00:00:00 2001 From: ChuufMaster Date: Fri, 18 Oct 2024 04:06:01 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9A=80=20Removed=20an=20unused=20push?= =?UTF-8?q?=20on=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/update_birds.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/update_birds.yml b/.github/workflows/update_birds.yml index 555f9d73..bf5a0ad8 100644 --- a/.github/workflows/update_birds.yml +++ b/.github/workflows/update_birds.yml @@ -5,9 +5,6 @@ on: - cron: "0 8 * * *" workflow_dispatch: workflow_call: - push: - branches: - - dev/fix/auto_import jobs: update_data: