def self.score_conversion!(test_name)
test_name.gsub!(" ", "_")
participating_tests = Abingo.cache.read("Abingo::participating_tests::#{Abingo.identity}") || []
ABingoCampingPlugin.logger.debug "score_conversion (#{test_name}) participating_tests=#{participating_tests.inspect} flag=#{participating_tests.include?(test_name)} options=#{options.inspect}"
if options[:assume_participation] || participating_tests.include?(test_name)
cache_key = "Abingo::conversions(#{Abingo.identity},#{test_name}"
ABingoCampingPlugin.logger.debug "score_conversion cache_key=#{cache_key}"
if options[:multiple_conversions] || !Abingo.cache.read(cache_key)
ABingoCampingPlugin.logger.debug "score_conversion is human=#{!options[:count_humans_only] || Abingo.is_human?}"
if !options[:count_humans_only] || Abingo.is_human?
ABingoCampingPlugin::Models::Alternative.score_conversion(test_name)
end
if Abingo.cache.exist?(cache_key)
ABingoCampingPlugin.logger.debug "score_conversion increment #{cache_key}"
Abingo.cache.increment(cache_key)
else
ABingoCampingPlugin.logger.debug "score_conversion write #{cache_key}"
Abingo.cache.write(cache_key, 1)
end
end
end
end