aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Script/Alerts.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2019-12-09 14:51:57 +0000
committerMatthew Somerville <matthew@mysociety.org>2019-12-09 18:56:15 +0000
commitbd3fbd345cebb859a5d97ce6d5a11b61c08ad3da (patch)
tree8b8aa7551efbae27820d62ebc8e967791810f0f0 /perllib/FixMyStreet/Script/Alerts.pm
parent13ac40394d1013c2179b8205f18ad2a3d69d2493 (diff)
[TfL] Exclude TfL items from non-TfL email alerts.
Diffstat (limited to 'perllib/FixMyStreet/Script/Alerts.pm')
-rw-r--r--perllib/FixMyStreet/Script/Alerts.pm8
1 files changed, 7 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Script/Alerts.pm b/perllib/FixMyStreet/Script/Alerts.pm
index d0b43b30f..cb1f022fa 100644
--- a/perllib/FixMyStreet/Script/Alerts.pm
+++ b/perllib/FixMyStreet/Script/Alerts.pm
@@ -40,6 +40,7 @@ sub send() {
$item_table.confirmed as item_confirmed,
$item_table.photo as item_photo,
$item_table.problem_state as item_problem_state,
+ $item_table.cobrand as item_cobrand,
$head_table.*
from alert, $item_table, $head_table
where alert.parameter::integer = $head_table.id
@@ -47,6 +48,7 @@ sub send() {
";
} else {
$query .= " $item_table.*,
+ $item_table.cobrand as item_cobrand,
$item_table.id as item_id
from alert, $item_table
where 1 = 1";
@@ -84,6 +86,8 @@ sub send() {
next unless FixMyStreet::DB::Result::Problem::visible_states()->{$row->{state}};
+ next if $row->{alert_cobrand} ne 'tfl' && $row->{item_cobrand} eq 'tfl';
+
$schema->resultset('AlertSent')->create( {
alert_id => $row->{alert_id},
parameter => $row->{item_id},
@@ -248,7 +252,7 @@ sub send() {
cobrand_data => $alert->cobrand_data,
schema => $schema,
);
- my $q = "select problem.id, problem.bodies_str, problem.postcode, problem.geocode, problem.confirmed,
+ my $q = "select problem.id, problem.bodies_str, problem.postcode, problem.geocode, problem.confirmed, problem.cobrand,
problem.title, problem.detail, problem.photo from problem_find_nearby(?, ?, ?) as nearby, problem, users
where nearby.problem_id = problem.id
and problem.user_id = users.id
@@ -261,6 +265,8 @@ sub send() {
$q = FixMyStreet::DB->schema->storage->dbh->prepare($q);
$q->execute($latitude, $longitude, $d, $alert->whensubscribed, $alert->id, $alert->user->email);
while (my $row = $q->fetchrow_hashref) {
+ next if $alert->cobrand ne 'tfl' && $row->{cobrand} eq 'tfl';
+
$schema->resultset('AlertSent')->create( {
alert_id => $alert->id,
parameter => $row->{id},