Navigation Menu

Skip to content

Commit

Permalink
groonga: Convert "sortby" option
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 28, 2014
1 parent c29792f commit d0ff25e
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/droonga/plugins/groonga/select.rb
Expand Up @@ -31,6 +31,20 @@ def convert(select_request)
offset = (select_request["offset"] || "0").to_i
limit = (select_request["limit"] || "10").to_i

output_offset = offset
output_limit = limit

sort_by = nil
sort_keys = (select_request["sortby"] || "").split(",")
unless sort_keys.empty?
sort_by = {
"keys" => sort_keys,
"offset" => offset,
"limit" => limit,
}
output_offset = 0
end

search_request = {
"queries" => {
@result_name => {
Expand All @@ -44,12 +58,15 @@ def convert(select_request)
"records",
],
"attributes" => attributes,
"offset" => offset,
"limit" => limit,
"offset" => output_offset,
"limit" => output_limit,
},
}
}
}
if sort_by
search_request["queries"][@result_name]["sortBy"] = sort_by
end

condition = convert_condition(select_request)
if condition
Expand Down

0 comments on commit d0ff25e

Please sign in to comment.