Skip to content

Commit

Permalink
Delete expired sitter_auths
Browse files Browse the repository at this point in the history
  • Loading branch information
Iain C Docherty committed Feb 27, 2016
1 parent 5ac31c8 commit fbe3c28
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions bin/clean_up_sitterauths.pl
Expand Up @@ -15,24 +15,32 @@

my $rs = Lacuna->db->resultset("SitterAuths");

# we do not warn about expired auths since we've already warned them for the
# previous AUTH_WARNING_DAYS days.
out("Checking for messages to send.");

my $soon = DateTime->now()->add(days => $rs->AUTH_WARNING_DAYS);
my $dtf = Lacuna->db->storage->datetime_parser;

out("Checking for sitter_auths to delete.");
# Delete any that have already expired
#
$rs->search({
expiry => {
'<' => $dtf->format_datetime(DateTime->now),
}
})->delete;

# we do not warn about expired auths since we've already warned them for the
# previous AUTH_WARNING_DAYS days.

out("Checking for messages to send.");
my $warnings = $rs->search({
expiry => {
'<' => $dtf->format_datetime($soon),
'>' => $dtf->format_datetime(DateTime->now),
},
},{
join => ['sitter', 'baby'],
'+select' => [ 'sitter.name', 'baby.name' ],
'+as' => [ 'sitter_name', 'baby_name' ],
},
);
},{
join => [ 'sitter', 'baby' ],
'+select' => [ 'sitter.name', 'baby.name' ],
'+as' => [ 'sitter_name', 'baby_name' ],
});

my %expiring_sitters;
my %expiring_babies;
Expand Down Expand Up @@ -91,7 +99,6 @@

out("Done.");

our $quiet;
sub out {
unless ($quiet) {
say DateTime->now, " ", @_;
Expand Down

0 comments on commit fbe3c28

Please sign in to comment.