Sha256: 288a88857b2077e85a6fc46f03395fe2900ed545f101c2261a45e731fbd7e04a

Contents?: true

Size: 926 Bytes

Versions: 7

Compression:

Stored size: 926 Bytes

Contents

class SyncAllTicketsJob

  class QuitAll < RuntimeError; end


  def self.run!
    new.run!
  end

  def run!
    Project \
      .unretired
      .where(Project.arel_table[:ticket_tracker_name].not_in(%w{None Houston}))
      .each(&method(:update_tickets_for_project!))
  rescue QuitAll
  end

  def update_tickets_for_project!(project)
    SyncProjectTicketsJob.new(project).run!

  rescue Houston::Adapters::TicketTracker::ConnectionError
    retry if (connection_retry_count += 1) < 3
    connection_error!(project)
  rescue Houston::Adapters::TicketTracker::InvalidQueryError
    query_error!(project)
  ensure
    sleep 2 # give Unfuddle a break
  end


private

  def initialize
    @connection_retry_count = 0
  end

  attr_reader :connection_retry_count

  def connection_error!(project)
    Houston.report_exception $!
    raise QuitAll
  end

  def query_error!(project)
    Houston.report_exception $!
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
houston-core-0.5.6 app/jobs/sync_all_tickets_job.rb
houston-core-0.5.5 app/jobs/sync_all_tickets_job.rb
houston-core-0.5.4 app/jobs/sync_all_tickets_job.rb
houston-core-0.5.3 app/jobs/sync_all_tickets_job.rb
houston-core-0.5.2 app/jobs/sync_all_tickets_job.rb
houston-core-0.5.1 app/jobs/sync_all_tickets_job.rb
houston-core-0.5.0 app/jobs/sync_all_tickets_job.rb