Ejemplo n.º 1
0
        if (strpos($day, "-") === false) {
            if (intval($day) == $day_of_month || $day == $day_of_week || $day == "") {
                $process_session = true;
            }
        } else {
            $week = substr($day, 0, strpos($day, "-"));
            $dow = substr($day, strpos($day, "-") + 1, 1);
            if ($week == $week_of_month && $dow == $day_of_week) {
                $process_session = true;
            }
        }
    }
    # Scrape the session if the schedule is met
    if ($process_session) {
        get_propositions($session, 1);
        get_propositions_committees($session, 1);
        get_candidate_names($session, 1);
        get_candidate_data($session, 1);
        $result = $script_db->prepare("UPDATE cal_access_sessions SET last_ran = NOW() WHERE session = ?");
        $result->execute(array($session));
    }
}
# check for missing proposition committes
$query = "SELECT cal_access_propositions_committees.session, cal_access_propositions_committees.filer_id FROM cal_access_propositions_committees\n          LEFT JOIN cal_access_committees ON (cal_access_committees.filer_id = cal_access_propositions_committees.filer_id AND cal_access_committees.session = cal_access_propositions_committees.session)\n          WHERE ISNULL(cal_access_committees.filer_id)";
$result = $script_db->prepare($query);
$result->execute();
foreach ($result->fetchAll(PDO::FETCH_ASSOC) as $row) {
    $session = $row["session"];
    $filer_id = $row["filer_id"];
    get_committee_information($session, $filer_id, 1);
}
Ejemplo n.º 2
0
echo "Installing smry_tables.sql... \n";
# Create tables used for fast web searches
process_sql_file("install_smry_tables.sql");
echo "Installing populated.sql... \n";
# Create populated tables (name parse tables and state name table)
process_sql_file("install_populated.sql");
echo "Populating all cal_access sessions from http://www.sos.ca.gov/elections/elections_cand.htm \n";
# Populate all cal_access sessions
get_elections_list();
echo "Scraping the cal-access data for all sessions (this process can take up to 8 - 10 hours) \n";
$result = $script_db->prepare("SELECT session FROM cal_access_sessions ORDER BY session DESC");
$result->execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
    echo "Retrieving data for session " . $row["session"] . "\n";
    get_propositions($row["session"], 1);
    get_propositions_committees($row["session"], 1);
    get_candidate_names($row["session"], 1);
    get_candidate_data($row["session"], 1);
    $result2 = $script_db->prepare("UPDATE cal_access_sessions SET last_ran = NOW() WHERE session = ?");
    $result2->execute(array($row["session"]));
}
echo "check for missing proposition committes \n";
$query = "SELECT cal_access_propositions_committees.session, cal_access_propositions_committees.filer_id FROM cal_access_propositions_committees\n            LEFT JOIN cal_access_committees ON (cal_access_committees.filer_id = cal_access_propositions_committees.filer_id AND cal_access_committees.session = cal_access_propositions_committees.session)\n            WHERE ISNULL(cal_access_committees.filer_id)";
$result = $script_db->prepare($query);
$result->execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
    $session = $row["session"];
    $filer_id = $row["filer_id"];
    get_committee_information($session, $filer_id, 1);
}
echo "check for missing candidate committes \n";