Sha256: c4313e0dc85d91903417446361f1957d3a0a863e7a238854c57e0996f7cab288

Contents?: true

Size: 732 Bytes

Versions: 16

Compression:

Stored size: 732 Bytes

Contents

require 'mkit/app/helpers/erb_helper'
require 'mkit/app/helpers/docker_helper'
require 'mkit/app/model/service'
require 'mkit/status'

class MkitJob < ActiveRecord::Base
  before_destroy :clean_up

  STATUS = %w{READY PROCESSING FAILED}

  def self.take
    MkitJob.where(status: 'READY').group(:service_id, :pod_id).take
  end

  def self.publish(*args)
    job = MkitJob.new(args[0])
    job.status = 'READY'
    job.save
    job
  end

  def processing!
    self.status='PROCESSING'
    self.save
  end

  def error!
    self.status='FAILED'
    self.save
  end

  def data=(opt={})
    self.payload=opt.to_json
  end

  def data
    JSON.parse(self.payload)
  end

  def done!
    self.destroy
  end

  def clean_up
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mkit-0.9.0 lib/mkit/app/model/mkit_job.rb
mkit-0.8.0 lib/mkit/app/model/mkit_job.rb
mkit-0.7.2 lib/mkit/app/model/mkit_job.rb
mkit-0.7.1 lib/mkit/app/model/mkit_job.rb
mkit-0.7.0 lib/mkit/app/model/mkit_job.rb
mkit-0.6.3 lib/mkit/app/model/mkit_job.rb
mkit-0.6.2 lib/mkit/app/model/mkit_job.rb
mkit-0.6.1 lib/mkit/app/model/mkit_job.rb
mkit-0.6.0 lib/mkit/app/model/mkit_job.rb
mkit-0.5.0 lib/mkit/app/model/mkit_job.rb
mkit-0.4.3 lib/mkit/app/model/mkit_job.rb
mkit-0.4.2 lib/mkit/app/model/mkit_job.rb
mkit-0.4.1 lib/mkit/app/model/mkit_job.rb
mkit-0.4.0 lib/mkit/app/model/mkit_job.rb
mkit-0.3.0 lib/mkit/app/model/mkit_job.rb
mkit-0.2.0 lib/mkit/app/model/mkit_job.rb