aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/ResultSet/Alert.pm
blob: 62e6120e4f75d25989546f1aef872ff0777b708f (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
34
35
36
37
38
package FixMyStreet::DB::ResultSet::Alert;
use base 'DBIx::Class::ResultSet';

use strict;
use warnings;

sub timeline_created {
    my ( $rs, $restriction ) = @_;

    my $prefetch = 
        FixMyStreet::App->model('DB')->schema->storage->sql_maker->quote_char ?
        [ qw/alert_type user/ ] :
        [ qw/alert_type/ ];

    return $rs->search(
        {
            whensubscribed => { '>=', \"ms_current_timestamp()-'7 days'::interval" },
            confirmed => 1,
            %{ $restriction },
        },
        {
            prefetch => $prefetch,
        }
    );
}

sub timeline_disabled {
    my ( $rs, $restriction ) = @_;

    return $rs->search(
        {
            whendisabled => { '>=', \"ms_current_timestamp()-'7 days'::interval" },
            %{ $restriction },
        },
    );
}

1;