<commit_before><?php

###
# List Votes
#
# PURPOSE
# List how legislators voted on this particular vote.
#
###

# INCLUDES
# Include any files or libraries that are necessary for this specific
# page to function.
include_once 'includes/settings.inc.php';
include_once 'includes/functions.inc.php';
include_once 'vendor/autoload.php';

# DECLARATIVE FUNCTIONS
# Run those functions that are necessary prior to loading this specific
# page.
$database = new Database;
$database->connect_old();

# INITIALIZE SESSION
session_start();

# LOCALIZE AND CLEAN UP VARIABLES
if (isset($_GET['lis_id']))
{
    $lis_id = strtoupper($_GET['lis_id']);
}
else
{
    die();
}
if (isset($_GET['year']))
{
    $year = $_GET['year'];
}
if (isset($_GET['bill']))
{
    $bill = $_GET['bill'];
}

$html_head = '';

# PAGE METADATA
$page_title = 'Vote';
$site_section = '';

# PAGE CONTENT

# Select information about this bill.
$sql = 'SELECT bills.id, bills.number, bills.session_id, bills.chamber, bills.catch_line,
		bills.chief_patron_id, bills.summary, bills.notes, representatives.name AS patron,
		districts.number AS patron_district, sessions.year, bills_status.status AS status_line,
		bills_status.translation AS status_line_translation,
		DATE_FORMAT("%m/%d/%Y", bills_status.date) AS status_line_date,
		representatives.party AS patron_party, representatives.chamber AS patron_chamber,
		representatives.shortname AS patron_shortname, committees.name AS committee_name,
		committees.shortname AS committee_shortname
		FROM bills
		LEFT JOIN votes
			ON bills.id=votes.bill_id
		LEFT JOIN sessions
			ON sessions.id=bills.session_id
		LEFT JOIN representatives
			ON representatives.id=bills.chief_patron_id
		LEFT JOIN districts
			ON representatives.district_id=districts.id
		LEFT JOIN bills_status
			ON bills_status.lis_vote_id=votes.lis_id
		LEFT JOIN committees
			ON votes.committee_id=committees.id
		WHERE bills.number="'.$bill.'" AND sessions.year='.$year;
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0)
{
    $bill = mysql_fetch_assoc($result);
    $bill = array_map('stripslashes', $bill);
    $bill = array_map('trim', $bill);
}

/*
 * Create a new instance of the Vote class, and get aggregate data about the outcome.
 */
$vote_info = new Vote;
$vote = $vote_info->get_aggregate($lis_id, $bill['session_id']);

$page_title = strtoupper($bill['number']) . ': ' . $bill['catch_line'];
$page_body = '<p>';
if (!empty($bill['committee_name']))
{
    $page_body .= 'This vote on <a href="/bill/'.$year.'/'.$bill['number'].'/">'.strtoupper($bill['number']).'</a>
	was held in the <a href="/committee/'.$vote['chamber'].'/'.$bill['committee_shortname'].'/">'.ucfirst($vote['chamber']).'
	'.$bill['committee_name'].'</a> committee.  ';
}
else
{
    $page_body .= 'This vote on <a href="/bill/'.$year.'/'.$bill['number'].'/">'
        .strtoupper($bill['number']).'</a> was held in the '.ucfirst($vote['chamber']).'.  ';
}
$page_body .= 'This vote '.$vote['outcome'].'ed '.$vote['tally'].'.</p>';

/*
 * Get detailed information about the vote -- who voted how.
 */
$legislators = $vote_info->get_detailed($lis_id, $bill['session_id']);

# Step through the legislators data to establish which party voted which way, building up
# an array of data.
foreach ($legislators as $legislator)
{
    $legislator['vote'] = strtolower($legislator['vote']);
    $legislator['party'] = strtolower($legislator['party']);
    $graph[$legislator{vote}][$legislator{party}]++;
    $parties[$legislator{party}] = 1;
}

# Make sure that we don't have any missing data, party-wise. That is, Google gets sad if
# we list Democrats, Republicans, and Independents for a "yes" vote, but only Democrats
# and Republicans for a "no" vote. So if any Independents voted anywhere, we need to make
# sure that they're listed everywhere, with a "0".
foreach ($parties as $party => $blargh)
{
    foreach ($graph as &$vote)
    {<commit_msg>Quote values properly<commit_after><?php

###
# List Votes
#
# PURPOSE
# List how legislators voted on this particular vote.
#
###

# INCLUDES
# Include any files or libraries that are necessary for this specific
# page to function.
include_once 'includes/settings.inc.php';
include_once 'includes/functions.inc.php';
include_once 'vendor/autoload.php';

# DECLARATIVE FUNCTIONS
# Run those functions that are necessary prior to loading this specific
# page.
$database = new Database;
$database->connect_old();

# INITIALIZE SESSION
session_start();

# LOCALIZE AND CLEAN UP VARIABLES
if (isset($_GET['lis_id']))
{
    $lis_id = strtoupper($_GET['lis_id']);
}
else
{
    die();
}
if (isset($_GET['year']))
{
    $year = $_GET['year'];
}
if (isset($_GET['bill']))
{
    $bill = $_GET['bill'];
}

$html_head = '';

# PAGE METADATA
$page_title = 'Vote';
$site_section = '';

# PAGE CONTENT

# Select information about this bill.
$sql = 'SELECT bills.id, bills.number, bills.session_id, bills.chamber, bills.catch_line,
		bills.chief_patron_id, bills.summary, bills.notes, representatives.name AS patron,
		districts.number AS patron_district, sessions.year, bills_status.status AS status_line,
		bills_status.translation AS status_line_translation,
		DATE_FORMAT("%m/%d/%Y", bills_status.date) AS status_line_date,
		representatives.party AS patron_party, representatives.chamber AS patron_chamber,
		representatives.shortname AS patron_shortname, committees.name AS committee_name,
		committees.shortname AS committee_shortname
		FROM bills
		LEFT JOIN votes
			ON bills.id=votes.bill_id
		LEFT JOIN sessions
			ON sessions.id=bills.session_id
		LEFT JOIN representatives
			ON representatives.id=bills.chief_patron_id
		LEFT JOIN districts
			ON representatives.district_id=districts.id
		LEFT JOIN bills_status
			ON bills_status.lis_vote_id=votes.lis_id
		LEFT JOIN committees
			ON votes.committee_id=committees.id
		WHERE bills.number="'.$bill.'" AND sessions.year='.$year;
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0)
{
    $bill = mysql_fetch_assoc($result);
    $bill = array_map('stripslashes', $bill);
    $bill = array_map('trim', $bill);
}

/*
 * Create a new instance of the Vote class, and get aggregate data about the outcome.
 */
$vote_info = new Vote;
$vote = $vote_info->get_aggregate($lis_id, $bill['session_id']);

$page_title = strtoupper($bill['number']) . ': ' . $bill['catch_line'];
$page_body = '<p>';
if (!empty($bill['committee_name']))
{
    $page_body .= 'This vote on <a href="/bill/'.$year.'/'.$bill['number'].'/">'.strtoupper($bill['number']).'</a>
	was held in the <a href="/committee/'.$vote['chamber'].'/'.$bill['committee_shortname'].'/">'.ucfirst($vote['chamber']).'
	'.$bill['committee_name'].'</a> committee.  ';
}
else
{
    $page_body .= 'This vote on <a href="/bill/'.$year.'/'.$bill['number'].'/">'
        .strtoupper($bill['number']).'</a> was held in the '.ucfirst($vote['chamber']).'.  ';
}
$page_body .= 'This vote '.$vote['outcome'].'ed '.$vote['tally'].'.</p>';

/*
 * Get detailed information about the vote -- who voted how.
 */
$legislators = $vote_info->get_detailed($lis_id, $bill['session_id']);

# Step through the legislators data to establish which party voted which way, building up
# an array of data.
foreach ($legislators as $legislator)
{
    $legislator['vote'] = strtolower($legislator['vote']);
    $legislator['party'] = strtolower($legislator['party']);
    $graph[$legislator{'vote'}][$legislator{'party'}]++;
    $parties[$legislator{'party'}] = 1;
}

# Make sure that we don't have any missing data, party-wise. That is, Google gets sad if
# we list Democrats, Republicans, and Independents for a "yes" vote, but only Democrats
# and Republicans for a "no" vote. So if any Independents voted anywhere, we need to make
# sure that they're listed everywhere, with a "0".
foreach ($parties as $party => $blargh)
{
    foreach ($graph as &$vote)
    {
{'fraction_non_alphanumeric': 0.15940921823274765, 'fraction_numerical': 0.0007639419404125286, 'mean_word_length': 4.805617147080562, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2077669', 'n_tokens_mistral': 2770, 'n_tokens_neox': 2578, 'n_words': 682}