Kouhei Sutou
null+****@clear*****
Mon Mar 24 22:51:44 JST 2014
Kouhei Sutou 2014-03-24 22:51:44 +0900 (Mon, 24 Mar 2014) New Revision: 74addb16b84c0dabbb95d4851498c5402436000c https://github.com/droonga/drntest/commit/74addb16b84c0dabbb95d4851498c5402436000c Message: Support normalizing elapsedTime in search response Modified files: lib/drntest/response-normalizer.rb Modified: lib/drntest/response-normalizer.rb (+25 -4) =================================================================== --- lib/drntest/response-normalizer.rb 2014-03-24 14:51:35 +0900 (fa852a8) +++ lib/drntest/response-normalizer.rb 2014-03-24 22:51:44 +0900 (ed8c2a6) @@ -41,8 +41,11 @@ module Drntest end def normalize_droonga_message_body!(body) - return unless groonga_command? - normalize_groonga_command_response!(body) + if groonga_command? + normalize_groonga_command_response!(body) + elsif search_command? + normalize_search_command_response!(body) + end end GROONGA_COMMANDS = [ @@ -55,6 +58,10 @@ module Drntest GROONGA_COMMANDS.include?(@request["type"]) end + def search_command? + @request["type"] == "search" + end + def normalize_droonga_message_envelope!(message) normalized_in_reply_to = "request-id" in_reply_to = message["inReplyTo"] @@ -77,14 +84,28 @@ module Drntest normalize_groonga_command_header!(response[0]) end + def normalized_start_time + 0.0 + end + + def normalized_elapsed + 0.0 + end + def normalize_groonga_command_header!(header) return unless header.is_a?(Array) - normalized_start_time = 0.0 - normalized_elapsed = 0.0 header[1] = normalized_start_time if valid_start_time?(header[1]) header[2] = normalized_elapsed if valid_elapsed?(header[2]) end + def normalize_search_command_response!(response) + response.each do |query_name, result| + if valid_elapsed?(result["elapsedTime"]) + result["elapsedTime"] = normalized_elapsed + end + end + end + def valid_start_time?(start_time) start_time.is_a?(Float) and start_time > 0 end -------------- next part -------------- HTML����������������������������...Download