Sha256: 360a6cb42d48274524fd47058dcb51742d89fa85e288e4d94b7a7c94aca6bfd2
Contents?: true
Size: 1.1 KB
Versions: 5
Compression:
Stored size: 1.1 KB
Contents
module Maestrano::Connector::Rails class Synchronization < ActiveRecord::Base # Keeping only 100 synchronizations per organization after_create :clean_synchronizations #=================================== # Associations #=================================== belongs_to :organization validates :status, presence: true def is_running? self.status == 'RUNNING' end def is_error? self.status == 'ERROR' end def is_success? self.status == 'SUCCESS' end def self.create_running(organization) Synchronization.create(organization_id: organization.id, status: 'RUNNING') end def set_success self.update_attributes(status: 'SUCCESS') end def set_error(msg) self.update_attributes(status: 'ERROR', message: msg) end def set_partial self.update_attributes(partial: true) end def clean_synchronizations count = self.organization.synchronizations.count if count > 100 self.organization.synchronizations.order('id ASC').limit(count - 100).destroy_all end end end end
Version data entries
5 entries across 5 versions & 1 rubygems