serialize :tasks_summary, Hash
before_create :ensure_unique_submit_id
before_create :ensure_script_version_is_commit
+ before_update :ensure_script_version_is_commit
has_many :commit_ancestors, :foreign_key => :descendant, :primary_key => :script_version
running: false)
end
+ def self.queue
+ self.where('started_at is ? and is_locked_by is ? and cancelled_at is ?',
+ nil, nil, nil).
+ order('priority desc, created_at')
+ end
+
protected
def ensure_script_version_is_commit
+ if self.is_locked_by and self.started_at
+ # Apparently client has already decided to go for it. This is
+ # needed to run a local job using a local working directory
+ # instead of a commit-ish.
+ return true
+ end
sha1 = Commit.find_by_commit_ish(self.script_version) rescue nil
if sha1
self.script_version = sha1