Sha256: 319d4aa9acdef4906ae941e04244b8994550067a4dc99af691f6ce4a12279535

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

require 'rest-client'

module Sync
  class SessionsWorker
    include Sidekiq::Worker

    sidekiq_options :retry => false, :queue => :sync

    def perform(from_time)
      sessions = SessionRecord.where("started_at > ?", from_time).order("started_at").all

      sessions.each do |session|
        Sidekiq::Logging.logger.info "- submitting session #{session.message_id}"

        providers = RestClient::Request.execute(
          :method       => :post,
          :url          => "#{Terminal.config.host}/session_records",
          :timeout      => 40,
          :open_timeout => 60,
          :payload => {
            :terminal => Terminal.keyword,
            :session_record => {
              :message_id => session.message_id,
              :started_at => session.started_at,
              :upstream   => session.upstream,
              :downstream => session.downstream,
              :time       => session.time
            }
          }
        )
      end

    rescue Exception => e
      Sidekiq::Logging.logger.warn e.to_s
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
smartkiosk-client-0.2.1 app/workers/sync/sessions_worker.rb
smartkiosk-client-0.2 app/workers/sync/sessions_worker.rb
smartkiosk-client-0.1.19 app/workers/sync/sessions_worker.rb
smartkiosk-client-0.1.18 app/workers/sync/sessions_worker.rb
smartkiosk-client-0.1.17 app/workers/sync/sessions_worker.rb
smartkiosk-client-0.1.16 app/workers/sync/sessions_worker.rb
smartkiosk-client-0.1.15 app/workers/sync/sessions_worker.rb