Created
February 20, 2015 13:32
-
-
Save joeyfigaro/f4371e83fdab050e4b79 to your computer and use it in GitHub Desktop.
Grab data from see click fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# See Click Fix - Issues | |
# Collects Issues (1000 max) for each place_url | |
# for a given year | |
year=0 | |
last_year=0 | |
next_year=0 | |
if [ "$1" != "" ]; then | |
year=$1 | |
last_year=$((year-1)) | |
next_year=$((year+1)) | |
else | |
echo "You must pass a year as the fist parameter" | |
return | |
fi | |
# Place Urls for Richmond Places according to See Click Fix | |
place_urls=( richmond-precinct-1 vcu union-hill_henrico shockoe-slip monroe-ward gambles-hill gambles-hill belle-and-mayo-islands jackson-ward gilpin old-town-manchester va_henrico-county oregon-hill mosby_henrico southern-barton-heights chamberlayne-industrial-center) | |
# Start Date Range for each month | |
start_dates[1]=${last_year}-12-31 | |
start_dates[2]=${year}-01-31 | |
start_dates[3]=${year}-02-28 | |
start_dates[4]=${year}-03-31 | |
start_dates[5]=${year}-04-30 | |
start_dates[6]=${year}-05-31 | |
start_dates[7]=${year}-06-30 | |
start_dates[8]=${year}-07-31 | |
start_dates[9]=${year}-08-31 | |
start_dates[10]=${year}-09-30 | |
start_dates[11]=${year}-10-30 | |
start_dates[12]=${year}-11-31 | |
# End Date Range for each month | |
end_dates[1]=${year}-02-01 | |
end_dates[2]=${year}-03-01 | |
end_dates[3]=${year}-04-01 | |
end_dates[4]=${year}-05-01 | |
end_dates[5]=${year}-06-01 | |
end_dates[6]=${year}-07-01 | |
end_dates[7]=${year}-08-01 | |
end_dates[8]=${year}-09-01 | |
end_dates[9]=${year}-10-01 | |
end_dates[10]=${year}-11-01 | |
end_dates[11]=${year}-12-01 | |
end_dates[12]=${next_year}-01-01 | |
# Month Mapping | |
months[1]=jan | |
months[2]=feb | |
months[3]=mar | |
months[4]=apr | |
months[5]=may | |
months[6]=jun | |
months[7]=jul | |
months[8]=aug | |
months[9]=sep | |
months[10]=oct | |
months[11]=nov | |
months[12]=dec | |
echo "Creating Directory for the ${year}..." | |
mkdir -p ${year} | |
echo "Fetching Date for year ${year}..." | |
# Iterate over all place_urls elements | |
for i in ${place_urls[@]} | |
do | |
# Perform task for every month | |
for (( j = 1; j <= 12; j++ )) | |
do | |
echo "Fetching loacality: $i for ${months[$j]} (${year}/$i-${months[$j]}.json)" | |
# Call Api with appropriate parameters | |
curl -# -o ~/SeeClickFix/${year}/$i-${months[$j]}.json "https://seeclickfix.com/api/v2/issues?per_page=100&place_url=$i&after=${start_dates[$j]}T00:00:00-05:00&before=${end_dates[$j]}T00:00:00-05:00" | |
done | |
done | |
echo "Finished Fetching Data!"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment