Sha256: 083f6cf26153b4cf984d7a4f23d7309aa0cdbbda02a0d85a4ee4dae2192da9c6

Contents?: true

Size: 1.12 KB

Versions: 33

Compression:

Stored size: 1.12 KB

Contents

module Vanity
  module Commands
    class << self
      # Upgrade to newer version of Vanity (this usually means doing magic in
      # the database)
      def upgrade
        if Vanity.playground.connection.respond_to?(:redis)
          redis = Vanity.playground.connection.redis
          # Upgrade metrics from 1.3 to 1.4
          keys = redis.keys("metrics:*")
          if keys.empty?
            puts "No metrics to upgrade"
          else
            puts "Updating #{keys.map { |name| name.split(":")[1] }.uniq.length} metrics"
            keys.each do |key|
              key << ":value:0" if key[/\d{4}-\d{2}-\d{2}$/] 
              redis.renamenx key, "vanity:#{key}"
            end
          end
          # Upgrade experiments from 1.3 to 1.4
          keys = redis.keys("vanity:1:*")
          if keys.empty?
            puts "No experiments to upgrade"
          else
            puts "Updating #{keys.map { |name| name.split(":")[2] }.uniq.length} experiments"
            keys.each do |key|
              redis.renamenx key, key.gsub(":1:", ":experiments:")
            end
          end
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 6 rubygems

Version Path
vanity-1.9.3 lib/vanity/commands/upgrade.rb
vanity-1.9.2 lib/vanity/commands/upgrade.rb
vanity-1.8.4 lib/vanity/commands/upgrade.rb
vanity-2.0.0.beta3 lib/vanity/commands/upgrade.rb
vanity-2.0.0.beta2 lib/vanity/commands/upgrade.rb
vanity-2.0.0.beta lib/vanity/commands/upgrade.rb
vanity-1.9.1 lib/vanity/commands/upgrade.rb
vanity-1.9.0 lib/vanity/commands/upgrade.rb
vanity-1.9.0.beta lib/vanity/commands/upgrade.rb
vanity-1.8.3 lib/vanity/commands/upgrade.rb
vanity-1.8.3.beta2 lib/vanity/commands/upgrade.rb
vanity-1.8.3.beta lib/vanity/commands/upgrade.rb
vanity-1.8.2 lib/vanity/commands/upgrade.rb
vanity-1.8.1 lib/vanity/commands/upgrade.rb
lookout-vanity-1.8.2 lib/vanity/commands/upgrade.rb
moses-vanity-1.8.1 lib/vanity/commands/upgrade.rb
moses-vanity-1.8.0 lib/vanity/commands/upgrade.rb
vanity-1.8.0 lib/vanity/commands/upgrade.rb
moses-vanity-1.7.1 lib/vanity/commands/upgrade.rb
fiverr-vanity-1.7.2 lib/vanity/commands/upgrade.rb