19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/droonga/plugin/output_adapter/groonga/select.rb', line 19
def convert(search_response)
select_responses = search_response.collect do |key, value|
status_code = 0
start_time = value["startTime"]
start_time_in_unix_time = if start_time
Time.parse(start_time).to_f
else
Time.now.to_f
end
elapsed_time = value["elapsedTime"] || 0
count = value["count"]
attributes = value["attributes"] || []
converted_attributes = attributes.collect do |attribute|
name = attribute["name"]
type = attribute["type"]
[name, type]
end
= [status_code, start_time_in_unix_time, elapsed_time]
records = value["records"]
if records.empty?
results = [[count], converted_attributes]
else
results = [[count], converted_attributes, records]
end
body = [results]
[, body]
end
select_responses.first
end
|