-
-
Save anonymous/17c40715f7c407b184e0 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
diff --git a/lib/Minion/Backend/Pg.pm b/lib/Minion/Backend/Pg.pm | |
index 6e974f5..7e7c641 100644 | |
--- a/lib/Minion/Backend/Pg.pm | |
+++ b/lib/Minion/Backend/Pg.pm | |
@@ -59,19 +59,13 @@ sub job_info { | |
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 | |
+ where state = coalesce(?, state) and task = coalesce(?, task) | |
order by id desc | |
limit ? | |
- offset ?", @values, $limit, $offset | |
+ offset ?", @$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