Sha256: d1dd1c5ffb85c999df1d00a710ed828fec673141cbd334ffe4fd8fd4172742d3
Contents?: true
Size: 1004 Bytes
Versions: 2
Compression:
Stored size: 1004 Bytes
Contents
require 'split' require 'csv' require 'bigdecimal' if CSV.const_defined? :Reader require 'fastercsv' CSV = FasterCSV end module Split module Export extend self def round(number, precision = 2) BigDecimal.new(number.to_s).round(precision).to_f end def to_csv csv = CSV.generate do |csv| csv << ['Experiment', 'Alternative', 'Participants', 'Completed', 'Conversion Rate', 'Z score', 'Control', 'Winner'] Split::Experiment.all.each do |experiment| experiment.alternatives.each do |alternative| csv << [experiment.name, alternative.name, alternative.participant_count, alternative.completed_count, round(alternative.conversion_rate, 3), round(alternative.z_score, 3), alternative.control?, alternative.to_s == experiment.winner.to_s] end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
split-export-0.3.0 | lib/split/export.rb |
split-export-0.2.2 | lib/split/export.rb |