summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Kinkade <nath@nkinka.de>2014-03-11 23:50:18 +0000
committerNathan Kinkade <nath@nkinka.de>2014-03-11 23:50:18 +0000
commita5bdacd31ec51d2565c82f9583eb609f9501f967 (patch)
treef56cecf4733f740d45caf00fca181a468c2e9109
parent8060510d2f30263195ea5096895dfecadb857f35 (diff)
Overhauled way that non-sequential case numbers are attempted to be handled on each run.
-rwxr-xr-xdaily_run.sh50
1 files changed, 38 insertions, 12 deletions
diff --git a/daily_run.sh b/daily_run.sh
index 2a6295f..6dfeb3f 100755
--- a/daily_run.sh
+++ b/daily_run.sh
@@ -7,25 +7,51 @@ DATE=$(date -d 'yesterday' +'%A, %B %d, %Y')
# Get the highest current court_case_no from the database
YEAR=$(date +'%y')
PASSWD=$(cat ../mysql_passwd)
-QUERY="SELECT court_case_no FROM cases WHERE court_case_no LIKE 'f-$YEAR-%' ORDER BY id DESC LIMIT 1"
-CASE_NO=$(mysql -u root -p$PASSWD -ss -e "$QUERY" mdcc)
-CASE_ID=${CASE_NO:5}
+QUERY="SELECT court_case_no FROM cases WHERE court_case_no LIKE 'f-$YEAR-%' ORDER BY court_case_no DESC LIMIT 250"
+CASE_NOS=$(mysql -u root -p$PASSWD -ss -e "$QUERY" mdcc)
-# The case number in the database has leading zeros. Strip them off.
-START=$(echo $CASE_ID | sed 's/^0*//')
+# Turn list into an array
+cases=($CASE_NOS)
+
+MAX_CASE_NO="${cases[0]}"
+
+# Here we go back over the latest cases to fill in gaps, since the case numbers
+# are not always entered sequentially on any given day.
+idx=1
+shift
+for case in ${cases[@]}
+do
+ SEQ_PAD=${case:5}
+ SEQ=$(echo $SEQ_PAD | sed 's/^0*//')
+ if [[ ! -z ${cases[$idx]} ]]
+ then
+ NEXT_SEQ_PAD=${cases[$idx]:5}
+ NEXT_SEQ=$(echo $NEXT_SEQ_PAD | sed 's/^0*//')
+ if [ $NEXT_SEQ != $((SEQ-1)) ]
+ then
+ let "gap = SEQ - NEXT_SEQ"
+ let "GAP_START = NEXT_SEQ + 1"
+ let "GAP_STOP = SEQ - 1"
+ ./miami_dade_clerk_courts.py $GAP_START $GAP_STOP $YEAR
+ fi
+ let "idx = idx + 1"
+ fi
+done
-# At the very leading edge of cases they often enter case number out of
-# sequence. This is a minor attempt to go backward a bit to try to fill in the
-# blanks.
-((START = START - 25))
+CASE_SEQ_PAD=${MAX_CASE_NO:5}
+
+# The case number in the database has leading zeros. Strip them off.
+START=$(echo $CASE_SEQ_PAD | sed 's/^0*//')
-./miami_dade_clerk_courts.py $START $YEAR
+# Fetch all the latest entries
+./miami_dade_clerk_courts.py $START 0 $YEAR
-# Now get the new highest court_case_no after fetching all the latest
+# Get the new highest court_case_no after fetching all the latest
+QUERY="SELECT court_case_no FROM cases WHERE court_case_no LIKE 'f-$YEAR-%' ORDER BY court_case_no DESC LIMIT 1"
NEW_CASE_NO=$(mysql -u root -p$PASSWD -ss -e "$QUERY" mdcc)
# Send a link with the results to some people
RCPT_TO="udighe@gmail.com nath@nkinka.de"
SUBJECT="MDCC daily run for $DATE"
-BODY="http://li554-21.members.linode.com/search.php?between=$CASE_NO:$NEW_CASE_NO"
+BODY="http://dighelaw.com/mdcc/search.php?between=$MAX_CASE_NO:$NEW_CASE_NO"
echo $BODY | mail -s "$SUBJECT" $RCPT_TO