-
-
Save anonymous/937a2242bf539c1d5b4d 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..a31f57d 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 | |
+ 'select id | |
from minion_jobs | |
- $where | |
+ where (state = ? or ?::text is null) and (task = ? or ?::text is null) | |
order by id desc | |
limit ? | |
- offset ?", @values, $limit, $offset | |
+ offset ?', @$options{qw(state state task 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