| 1 | package Hopkins::Store::Schema::ResultSet::Task; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Hopkins::Store::Schema::ResultSet::Task - ResultSet class for Task | ||
| 6 | |||
| 7 | =head1 DESCRIPTION | ||
| 8 | |||
| 9 | this class houses ResultSet methods for the Task | ||
| 10 | ORM class. it provides niceties and convenience | ||
| 11 | methods. | ||
| 12 | |||
| 13 | =cut | ||
| 14 | |||
| 15 | use base 'DBIx::Class::ResultSet'; | ||
| 16 | |||
| 17 | =head1 METHODS | ||
| 18 | |||
| 19 | =over 4 | ||
| 20 | |||
| 21 | =item queued | ||
| 22 | |||
| 23 | restricts the ResultSet to only those Tasks that | ||
| 24 | have been queued but not started. | ||
| 25 | |||
| 26 | =cut | ||
| 27 | |||
| 28 | sub queued | ||
| 29 | { | ||
| 30 | return shift->search({ date_started => undef }); | ||
| 31 | } | ||
| 32 | |||
| 33 | =sub task_executed_since | ||
| 34 | |||
| 35 | given a task name and a DateTime object, returns a | ||
| 36 | boolean value indicating whether or not the task has | ||
| 37 | successfully executed since | ||
| 38 | |||
| 39 | =cut | ||
| 40 | |||
| 41 | sub task_executed_since | ||
| 42 | { | ||
| 43 | my $self = shift; | ||
| 44 | my $name = shift; | ||
| 45 | my $date = shift; | ||
| 46 | |||
| 47 | my $rs = $self->search({ name => $name, date_queued => { '>=', $date } }); | ||
| 48 | |||
| 49 | return $rs->count == 0 ? 0 : 1; | ||
| 50 | } | ||
| 51 | |||
| 52 | =sub task_executing_now | ||
| 53 | |||
| 54 | given a task name, returns a boolean value indicating | ||
| 55 | whether or not the task is currently running | ||
| 56 | |||
| 57 | =cut | ||
| 58 | |||
| 59 | sub task_executing_now | ||
| 60 | { | ||
| 61 | my $self = shift; | ||
| 62 | my $name = shift; | ||
| 63 | |||
| 64 | my $rs = $self->search({ name => $name, date_completed => undef }); | ||
| 65 | |||
| 66 | return $rs->count == 0 ? 0 : 1; | ||
| 67 | } | ||
| 68 | |||
| 69 | =back | ||
| 70 | |||
| 71 | =head1 AUTHOR | ||
| 72 | |||
| 73 | Mike Eldridge <diz@cpan.org> | ||
| 74 | |||
| 75 | =cut | ||
| 76 | |||
| 77 | 1; |