summaryrefslogtreecommitdiff
path: root/lib/ci/scheduler.rb
blob: ee0958f4be14cc03708385a6cba4aa49e0cb9309 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module Ci
  class Scheduler
    def perform
      projects = Ci::Project.where(always_build: true).all
      projects.each do |project|
        last_commit = project.commits.last
        next unless last_commit && last_commit.last_build

        interval = project.polling_interval
        if (last_commit.last_build.created_at + interval.hours) < Time.now
          last_commit.retry
        end
      end
    end
  end
end