diff options
author | Marius Halden <marius.h@lden.org> | 2017-11-03 16:13:59 +0100 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2017-11-03 16:13:59 +0100 |
commit | 42d874db498d0fabae92d0c87acf99054d92391b (patch) | |
tree | d0cf5afdee3d244c4e5da6fe1ab9acba620634df /perllib/FixMyStreet/DB/ResultSet/UserPlannedReport.pm | |
parent | 19a7c5dda85a47a68040c742791e9cd9d3e52be6 (diff) | |
parent | dc7613329c275cd158fdde8faf1c0e301f5b7202 (diff) |
Merge tag 'v2.2' into fiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/UserPlannedReport.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/UserPlannedReport.pm | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/UserPlannedReport.pm b/perllib/FixMyStreet/DB/ResultSet/UserPlannedReport.pm index 7e16e2dd3..460a4912e 100644 --- a/perllib/FixMyStreet/DB/ResultSet/UserPlannedReport.pm +++ b/perllib/FixMyStreet/DB/ResultSet/UserPlannedReport.pm @@ -6,7 +6,17 @@ use warnings; sub active { my $rs = shift; - $rs->search({ removed => undef }); + + # If we have been prefetched we can't use `active` as that'll blow away the + # cache and query the DB due to the `removed IS NULL` clause. So let's do + # the filtering here instead, if the query has been prefetched. + if ( $rs->get_cache ) { + my @users = grep { !defined($_->removed) } $rs->all; + $rs->set_cache(\@users); + $rs; + } else { + $rs->search({ removed => undef }); + } } sub for_report { |