diff --git a/utilities/update_legislators.php b/cron/legislators.php similarity index 71% rename from utilities/update_legislators.php rename to cron/legislators.php index cefec10..544b8ae 100644 --- a/utilities/update_legislators.php +++ b/cron/legislators.php @@ -1,17 +1,5 @@ now() ORDER BY chamber ASC'; -$stmt = $db->prepare($sql); +$stmt = $dbh->prepare($sql); $stmt->execute(); $known_legislators = $stmt->fetchAll(PDO::FETCH_OBJ); foreach ($known_legislators as &$known_legislator) @@ -37,7 +25,11 @@ } } -echo '
Loaded ' . count($known_legislators) . ' from local database.
'; +$log->put('Loaded ' . count($known_legislators) . ' from local database.', 1); +if (count($known_legislators) > 140) +{ + $log->put('There are ' . count($known_legislators) . ' legislators in the database—too many.', 5); +} /* * Get senators. Their Senate ID (e.g., "S100") is the key, their name is the value. @@ -54,7 +46,7 @@ $senators = $tmp; unset($tmp); -echo 'Retrieved ' . count($senators) . ' senators from senate.virginia.gov.
'; +$log->put('Retrieved ' . count($senators) . ' senators from senate.virginia.gov.', 1); /* * Get delegates. Their House ID (e.g., "H0200") is the key, their name is the value. @@ -71,7 +63,7 @@ $delegates = $tmp; unset($tmp); -echo 'Retrieved ' . count($delegates) . ' delegates from virginiageneralassembly.gov.
'; +$log->put('Retrieved ' . count($delegates) . ' delegates from virginiageneralassembly.gov.', 1); /* * First see if we have records of any representatives that are not currently in office. @@ -88,7 +80,7 @@ { if (!isset($senators[$id])) { - echo '