-
-
Save anonymous/1a159246c0bc25518956 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Old | |
sub list_jobs { | |
my ($self, $offset, $limit, $options) = @_; | |
my (@and, @values); | |
push @and, 'state = ?' and push @values, $options->{state} | |
if $options->{state}; | |
push @and, 'task = ?' and push @values, $options->{task} if $options->{task}; | |
my $where = @and ? 'where ' . join(' and ', @and) : ''; | |
return $self->pg->db->query( | |
"select id | |
from minion_jobs | |
$where | |
order by id desc | |
limit ? | |
offset ?", @values, $limit, $offset | |
)->arrays->map(sub { $self->job_info($_->[0]) })->to_array; | |
} | |
# New | |
sub list_jobs { | |
my ($self, $offset, $limit, $options) = @_; | |
return $self->pg->db->query( | |
'select id | |
from minion_jobs | |
where (state = $1 or $1::text is null) and (task = $2 or $2::text is null) | |
order by id desc | |
limit $3 | |
offset $4', @$options{qw(state task)}, $limit, $offset | |
)->arrays->map(sub { $self->job_info($_->[0]) })->to_array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment