Sha256: 4bfc5195a3e9f56a9a4883c737063acd58ec5de95069c52abceb09b9e958779c

Contents?: true

Size: 829 Bytes

Versions: 34

Compression:

Stored size: 829 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, _ = Sidekiq.redis do |r|
          r.multi do
            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

34 entries across 34 versions & 1 rubygems

Version Path
canvas_sync-0.17.26.beta1 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.24 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.23 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.23.beta8 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.23.beta7 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.23.beta6 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.23.beta5 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.23.beta4 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.23.beta2 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.23.beta1 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.20 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.19 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.18 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.17.beta1 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.16 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.15 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.14 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.13 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.12 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
canvas_sync-0.17.10.beta2 lib/canvas_sync/job_batches/sidekiq/web/helpers.rb