diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-11-28 00:59:01 +0300 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-11-28 02:36:50 +0300 |
commit | 13a902a9a42c0909ad8c6790c040447a9e12211f (patch) | |
tree | 6eb605aae6e13b77905e1df87b2d32842dffc07d /app/finders | |
parent | 9d27ce1630004e37cd0615830857a3135dc8d5fe (diff) |
Refactorize jobs finding logic
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/runner_jobs_finder.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/finders/runner_jobs_finder.rb b/app/finders/runner_jobs_finder.rb new file mode 100644 index 00000000000..52340f94523 --- /dev/null +++ b/app/finders/runner_jobs_finder.rb @@ -0,0 +1,22 @@ +class RunnerJobsFinder + attr_reader :runner, :params + + def initialize(runner, params = {}) + @runner = runner + @params = params + end + + def execute + items = @runner.builds + items = by_status(items) + items + end + + private + + def by_status(items) + return items unless HasStatus::AVAILABLE_STATUSES.include?(params[:status]) + + items.where(status: params[:status]) + end +end |