Skip to content

Commit

Permalink
πŸ”€ Merge pull request #371 from COS301-SE-2024/dev/fix/auto_import
Browse files Browse the repository at this point in the history
πŸ› οΈ Fixed some problems with running the correct tasks when importing birds
  • Loading branch information
ChuufMaster authored Oct 18, 2024
2 parents 488a7e4 + 8da44e5 commit bf23bd0
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions scripts/bash/auto_import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"

0 comments on commit bf23bd0

Please sign in to comment.