Sha256: 772de86186c8e44956ec5d5fd38b149786db600116e7cfae3f563570b6cb1b29

Contents?: true

Size: 855 Bytes

Versions: 47

Compression:

Stored size: 855 Bytes

Contents

# frozen_string_literal: true

module CanvasSync::JobBatches::Sidekiq
  module Web
    module Helpers
      VIEW_PATH    = File.expand_path("../web/views", __dir__)

      module_function

      def get_template(name)
        File.open(File.join(VIEW_PATH, "#{name}.erb")).read
      end

      def drain_zset(key)
        items, _ = CanvasSync::JobBatches::Batch.redis do |r|
          r.multi do |r|
            r.zrange(key, 0, -1)
            r.zremrangebyrank(key, 0, -1)
          end
        end
        yield items
      end

      def safe_relative_time(time)
        time = parse_time(time)
        relative_time(time)
      end

      def parse_time(time)
        case time
        when Time
          time
        when Integer, Float
          Time.at(time)
        else
          Time.parse(time.to_s)
        end
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
canvas_sync-0.21.1 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.21.1.beta1 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.21.0 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.21.0.beta5 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.21.0.beta4 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.21.0.beta3 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.21.0.beta2 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.21.0.beta1 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.20.5 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.20.4 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.20.3 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.19.1.beta2 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.19.1.beta1 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.19.0 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.19.0.beta10 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.19.0.beta9 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.19.0.beta8 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.19.0.beta7 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.19.0.beta6 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.19.0.beta5 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb