blob: 460a4912e1fd643e829889a16c876d5ae33f9bcc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package FixMyStreet::DB::ResultSet::UserPlannedReport;
use base 'DBIx::Class::ResultSet';
use strict;
use warnings;
sub active {
my $rs = shift;
# 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 {
my $rs = shift;
my $problem_id = shift;
$rs->search({ report_id => $problem_id });
}
sub remove {
my $rs = shift;
$rs->update({ removed => \'current_timestamp' });
}
1;
|