aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2016-02-09 14:43:38 +0000
committerMatthew Somerville <matthew@mysociety.org>2016-02-09 14:58:15 +0000
commitc5c308d37fef6ba9ab2676759f08f4de316ff543 (patch)
tree501035885184974a2fbb4293c85678137d4efc86 /perllib
parenta92cb4d9b33b48376cf3b66a76e2503c786c28e8 (diff)
Exclude update alerts from summary alert counts.
There might be the odd update alert we are interested in (those not auto-signed up for as part of report or update creation), but they will be rare.
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm2
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Alert.pm8
2 files changed, 9 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index 686d23aa1..693612b9c 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -91,7 +91,7 @@ sub index : Path : Args(0) {
$c->stash->{comments} = \%comment_counts;
- my $alerts = $c->model('DB::Alert')->summary_count( $c->cobrand->restriction );
+ my $alerts = $c->model('DB::Alert')->summary_report_alerts( $c->cobrand->restriction );
my %alert_counts =
map { $_->confirmed => $_->get_column('confirmed_count') } $alerts->all;
diff --git a/perllib/FixMyStreet/DB/ResultSet/Alert.pm b/perllib/FixMyStreet/DB/ResultSet/Alert.pm
index 1866e9b06..c61053fff 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Alert.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Alert.pm
@@ -35,6 +35,13 @@ sub timeline_disabled {
);
}
+# Return summary for alerts on reports (so excluding alerts on updates)
+sub summary_report_alerts {
+ my ( $rs, $restriction ) = @_;
+ $rs = $rs->search({ alert_type => { '!=', 'new_updates' } });
+ return $rs->summary_count($restriction);
+}
+
sub summary_count {
my ( $rs, $restriction ) = @_;
@@ -47,4 +54,5 @@ sub summary_count {
}
);
}
+
1;