lib/split/user.rb in split-1.4.4 vs lib/split/user.rb in split-1.4.5
- old
+ new
@@ -7,14 +7,15 @@
def initialize(context)
@user = Split::Persistence.adapter.new(context)
end
def cleanup_old_experiments!
- user.keys.each do |key|
+ keys_without_finished(user.keys).each do |key|
experiment = ExperimentCatalog.find key_without_version(key)
if experiment.nil? || experiment.has_winner? || experiment.start_time.nil?
user.delete key
+ user.delete Experiment.finished_key(key)
end
end
end
def max_experiments_reached?(experiment_key)
@@ -41,9 +42,13 @@
private
def keys_without_experiment(keys, experiment_key)
keys.reject { |k| k.match(Regexp.new("^#{experiment_key}(:finished)?$")) }
+ end
+
+ def keys_without_finished(keys)
+ keys.reject { |k| k.include?(":finished") }
end
def key_without_version(key)
key.split(/\:\d(?!\:)/)[0]
end