Mercurial Hosting > luan
changeset 295:1f4cc8505308
fix Ab_testing
git-svn-id: https://luan-java.googlecode.com/svn/trunk@296 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 12 Dec 2014 09:45:13 +0000 |
parents | 5652cdea25f5 |
children | 7ea6dfdf81ba |
files | dist/jars/luan-core-trunk.jar dist/jars/luan-logging-trunk.jar dist/jars/luan-lucene-trunk.jar dist/jars/luan-mail-trunk.jar dist/jars/luan-web-trunk.jar lucene/src/luan/modules/lucene/Ab_testing.luan |
diffstat | 6 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
diff -r 5652cdea25f5 -r 1f4cc8505308 dist/jars/luan-core-trunk.jar Binary file dist/jars/luan-core-trunk.jar has changed
diff -r 5652cdea25f5 -r 1f4cc8505308 dist/jars/luan-logging-trunk.jar Binary file dist/jars/luan-logging-trunk.jar has changed
diff -r 5652cdea25f5 -r 1f4cc8505308 dist/jars/luan-lucene-trunk.jar Binary file dist/jars/luan-lucene-trunk.jar has changed
diff -r 5652cdea25f5 -r 1f4cc8505308 dist/jars/luan-mail-trunk.jar Binary file dist/jars/luan-mail-trunk.jar has changed
diff -r 5652cdea25f5 -r 1f4cc8505308 dist/jars/luan-web-trunk.jar Binary file dist/jars/luan-web-trunk.jar has changed
diff -r 5652cdea25f5 -r 1f4cc8505308 lucene/src/luan/modules/lucene/Ab_testing.luan --- a/lucene/src/luan/modules/lucene/Ab_testing.luan Thu Dec 11 03:12:26 2014 +0000 +++ b/lucene/src/luan/modules/lucene/Ab_testing.luan Fri Dec 12 09:45:13 2014 +0000 @@ -2,8 +2,11 @@ import "luan:Table" import "luan:Io" import "luan:web/Http" +import "luan:logging/Logging" +local logger = Logging.logger "Ab_testing" + function of(index) local ab_testing = {} @@ -112,14 +115,15 @@ function ab_testing.to_doc(doc,values,tests) tests = tests or ab_testing.test_map if values == nil then - for _, test in ipairs(tests) do - doc[test.field] = test.values[Math.random(#test.values)] - end - else - for _, test in ipairs(tests) do - doc[test.field] = values[test.name] + values = {} + for _, test in pairs(tests) do + values[test.name] = test.values[Math.random(#test.values)] end end + for _, test in pairs(tests) do + doc[test.field] = values[test.name] + end + return values end function ab_testing.web_page(test_names)