Skip to content

Commit

Permalink
Add a house parameter to /divisions/
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Jan 15, 2024
1 parent c9c890a commit fafd34d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
23 changes: 13 additions & 10 deletions classes/Divisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,27 @@ public static function getMostRecentDivisionDate() {
*/
public function getRecentDivisions($number = 20, $houses = null) {
$select = '';
$where = '';
$order = 'ORDER BY division_date DESC, division_number DESC';
$limit = 'LIMIT :count';
$params = array(
':count' => $number
);

if ( is_string($houses) ) {
$houses = array( $houses );
$where = [];
if ($houses) {
if ( is_string($houses) ) {
$houses = array( $houses );
}
$where[] = 'house IN ("' . implode('", "', $houses) . '")';
}

if ( is_array($houses) && count($houses) > 0 ) {
$where = 'WHERE house IN ("' . implode('", "', $houses) . '")';
} elseif (LANGUAGE == 'cy') {
$where = "WHERE divisions.division_id NOT LIKE '%-en-%'";
} else {
$where = "WHERE divisions.division_id NOT LIKE '%-cy-%'";
if (!$houses || in_array('senedd', $houses)) {
if (LANGUAGE == 'cy') {
$where[] = "divisions.division_id NOT LIKE '%-en-%'";
} else {
$where[] = "divisions.division_id NOT LIKE '%-cy-%'";
}
}
$where = 'WHERE ' . join(' AND ', $where);

if ( $this->member ) {
$select = "SELECT divisions.*, vote FROM divisions
Expand Down
3 changes: 2 additions & 1 deletion www/docs/divisions/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
$MEMBER = new MySociety\TheyWorkForYou\Member(array('postcode' => $THEUSER->postcode(), 'house' => HOUSE_TYPE_COMMONS));
}

$houses = get_http_var('house', '', true);
$divisions = new MySociety\TheyWorkForYou\Divisions($MEMBER);
$data = $divisions->getRecentDivisions(30);
$data = $divisions->getRecentDivisions(30, $houses);

if (isset($MEMBER)) {
$data['mp_name'] = ucfirst($MEMBER->full_name());
Expand Down
2 changes: 1 addition & 1 deletion www/docs/style/sass/pages/_business.scss
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
margin: 0;
}

p {
p, ul {
margin: 0.5em 0 0 0;
font-size: 0.9em;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@

<p><?= gettext('This list contains votes from the House of Commons, House of Lords, Public Bill Committees, Senedd, and the Scottish Parliament.') ?></p>

<p><?= gettext('Only show votes from:') ?></p>
<ul>
<li><a href="?house=commons"><?= gettext('House of Commons') ?></a>
<li><a href="?house=lords"><?= gettext('House of Lords') ?></a>
<li><a href="?house=pbc"><?= gettext('Public Bill Committees') ?></a>
<li><a href="?house=scotland"><?= gettext('Scottish Parliament') ?></a>
<li><a href="?house=senedd"><?= gettext('Senedd') ?></a>
</ul>

<p class="voting-information-provenance">
<?= gettext('Some vote information from <a href="https://www.publicwhip.org.uk/">PublicWhip</a>.') ?>
<?= gettext('Last updated:') ?> <?= $last_updated ?>.
Expand Down

0 comments on commit fafd34d

Please sign in to comment.