Merge pull request #1 from github/include-a-timestamp-when-publishing-experiment-results

Add :timestamp to publish payload
This commit is contained in:
John Barnette 2013-02-26 15:25:00 -08:00
Родитель 2fe56209a9 59700248c4
Коммит cb33c05b1c
2 изменённых файлов: 5 добавлений и 0 удалений

Просмотреть файл

@ -50,6 +50,8 @@ module Dat
def run def run
return run_control unless candidate? && enabled? return run_control unless candidate? && enabled?
timestamp = Time.now
if control_runs_first? if control_runs_first?
control = observe_control control = observe_control
candidate = observe_candidate candidate = observe_candidate
@ -59,6 +61,7 @@ module Dat
end end
payload = { payload = {
:timestamp => timestamp,
:candidate => candidate.payload, :candidate => candidate.payload,
:control => control.payload, :control => control.payload,
:first => control_runs_first? ? :control : :candidate :first => control_runs_first? ? :control : :candidate

Просмотреть файл

@ -106,6 +106,8 @@ class DatScienceExperimentTest < MiniTest::Unit::TestCase
assert_equal "foo", payload[:experiment] assert_equal "foo", payload[:experiment]
assert_equal :control, payload[:first] assert_equal :control, payload[:first]
assert_in_delta Time.now.to_f, payload[:timestamp].to_f, 2.0
assert payload[:control][:duration] assert payload[:control][:duration]
assert_nil payload[:control][:exception] assert_nil payload[:control][:exception]
assert_equal :foo, payload[:control][:value] assert_equal :foo, payload[:control][:value]