Sha256: 94644ef3b448c47d2ac9ce49606914987df0f1567486283f370698b3e563162a

Contents?: true

Size: 553 Bytes

Versions: 2

Compression:

Stored size: 553 Bytes

Contents

module Gush
  class IndexWorkflowsByCreatedAtAndExpiresAt < Gush::Migration
    def self.version
      1
    end

    def up
      redis.scan_each(match: "gush.workflows.*").map do |key|
        id = key.sub("gush.workflows.", "")
        workflow = client.find_workflow(id)

        ttl = redis.ttl(key)
        redis.persist(key)
        workflow.jobs.each { |job| redis.persist("gush.jobs.#{id}.#{job.klass}") }

        client.persist_workflow(workflow)
        client.expire_workflow(workflow, ttl.positive? ? ttl : -1)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gush-4.1.0 lib/gush/migrate/1_create_gush_workflows_created.rb
gush-4.0.0 lib/gush/migrate/1_create_gush_workflows_created.rb