diff options
author | Struan Donald <struan@exo.org.uk> | 2011-06-07 16:46:05 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-06-07 16:46:05 +0100 |
commit | a82a51695eacf94b7523502b3a48e1de6836fec0 (patch) | |
tree | 214d4928cc0a71f8a56adcce913af9118cfb0b92 /perllib/FixMyStreet/DB/ResultSet/Alert.pm | |
parent | 00952f9a897777a4351f51c2728c52e43c6ea760 (diff) |
admin timeline
Diffstat (limited to 'perllib/FixMyStreet/DB/ResultSet/Alert.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/ResultSet/Alert.pm | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/ResultSet/Alert.pm b/perllib/FixMyStreet/DB/ResultSet/Alert.pm new file mode 100644 index 000000000..62e6120e4 --- /dev/null +++ b/perllib/FixMyStreet/DB/ResultSet/Alert.pm @@ -0,0 +1,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; |