diff src/luan/modules/lucene/Ab_testing.luan @ 1088:bae2d0c2576c

change module naming convention
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 26 Dec 2016 22:29:36 -0700
parents 1a68fc55a80c
children 5dbb552075ff
line wrap: on
line diff
--- a/src/luan/modules/lucene/Ab_testing.luan	Mon Dec 19 01:38:21 2016 -0700
+++ b/src/luan/modules/lucene/Ab_testing.luan	Mon Dec 26 22:29:36 2016 -0700
@@ -12,11 +12,11 @@
 local Logging = require "luan:logging/Logging.luan"
 local Lucene = require "luan:lucene/Lucene.luan"
 
-local M = {}
+local Ab_testing = {}
 
 local logger = Logging.logger "Ab_testing"
 
-function M.of(index)
+function Ab_testing.of(index)
 
 	local ab_testing = {}
 
@@ -94,8 +94,8 @@
 				for value, count in pairs(results[event]) do
 					fancy[event][value] = {}
 					fancy[event][value].count = count
-					fancy[event][value].pct_of_total = M.percent(count,all[value])
-					fancy[event][value].pct_of_prev = M.percent(count,prev[value])
+					fancy[event][value].pct_of_total = Ab_testing.percent(count,all[value])
+					fancy[event][value].pct_of_prev = Ab_testing.percent(count,prev[value])
 				end
 				prev = results[event]
 			end
@@ -143,7 +143,7 @@
 				results[name] = test.fancy_results()
 			end
 			Io.stdout = Http.response.text_writer()
-			M.html(test_names,ab_testing.test_map,results)
+			Ab_testing.html(test_names,ab_testing.test_map,results)
 		end
 	end
 
@@ -154,7 +154,7 @@
 -- aggregator factories
 
 -- fn(doc) should return boolean whether doc should be counted
-function M.count(fn)
+function Ab_testing.count(fn)
 	return function()
 		local aggregator = {}
 		aggregator.result = 0
@@ -167,10 +167,10 @@
 	end
 end
 
-M.count_all = M.count( function(doc) return true end )
+Ab_testing.count_all = Ab_testing.count( function(doc) return true end )
 
 -- fn(doc) should return number to add to result, return 0 for nothing
-function M.sum(fn)
+function Ab_testing.sum(fn)
 	return function()
 		local aggregator = {}
 		aggregator.result = 0
@@ -183,7 +183,7 @@
 
 
 
-function M.percent(x,total)
+function Ab_testing.percent(x,total)
 	if total==0 then
 		return 0
 	else
@@ -207,7 +207,7 @@
 	return gsub( v, [[(\d+\.\d{1})\d+]], '$1' )
 end
 
-function M.html(test_names,tests,results) %>
+function Ab_testing.html(test_names,tests,results) %>
 <!DOCTYPE html>
 <html lang="en">
 	<head>
@@ -269,4 +269,4 @@
 </html>
 <% end
 
-return M
+return Ab_testing