Skip to content

Commit

Permalink
do not include votes in alerts if ignore_speaker_votes flag set
Browse files Browse the repository at this point in the history
Skips over the vote section if the flag is present.
  • Loading branch information
struan committed Dec 5, 2024
1 parent 3ef1f85 commit 075ce8d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/alertmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ function mlog($message) {
continue;
}
$criteria_raw = $alertitem['criteria'];
$include_votes = $alertitem['ignore_speaker_votes'] == 0;
if (preg_match('#\bOR\b#', $criteria_raw)) {
$criteria_raw = "($criteria_raw)";
}
Expand Down Expand Up @@ -249,7 +250,7 @@ function mlog($message) {
mlog(", hits " . $total_results . ", time " . (getmicrotime() - $start) . "\n");

# Divisions
if (preg_match('#^speaker:(\d+)$#', $criteria_raw, $m)) {
if ($include_votes && preg_match('#^speaker:(\d+)$#', $criteria_raw, $m)) {
$pid = $m[1];
$q = $db->query('SELECT * FROM persondivisionvotes pdv JOIN divisions USING(division_id)
WHERE person_id=:person_id AND pdv.lastupdate >= :time', [
Expand Down
1 change: 1 addition & 0 deletions www/includes/easyparliament/alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public function fetch($confirmed, $deleted) {
criteria,
registrationtoken,
lang,
ignore_speaker_votes,
deleted,
confirmed
FROM alerts
Expand Down

0 comments on commit 075ce8d

Please sign in to comment.