From 5cf7a027db42b737bdffdd92d41fafb85659bc34 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Wed, 30 Oct 2024 14:43:38 +0000 Subject: [PATCH] do not include votes in alerts if ignore_speaker_votes flag set Skips over the vote section if the flag is present. --- scripts/alertmailer.php | 3 ++- www/includes/easyparliament/alert.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/alertmailer.php b/scripts/alertmailer.php index 03faba7b63..7766461c92 100644 --- a/scripts/alertmailer.php +++ b/scripts/alertmailer.php @@ -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)"; } @@ -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', [ diff --git a/www/includes/easyparliament/alert.php b/www/includes/easyparliament/alert.php index 226b6991e6..54f99adc61 100644 --- a/www/includes/easyparliament/alert.php +++ b/www/includes/easyparliament/alert.php @@ -90,6 +90,7 @@ public function fetch($confirmed, $deleted) { criteria, registrationtoken, lang, + ignore_speaker_votes, deleted, confirmed FROM alerts