fixed type and added sort param
This commit is contained in:
parent
0887a8c8fc
commit
1addbe31b4
@ -389,6 +389,18 @@ class MongoConnector
|
||||
options.delete("date_to")
|
||||
options["created_at"] = date unless date.empty?
|
||||
end
|
||||
if options.has_key?("type")
|
||||
begin
|
||||
options["type"] = Integer(options["type"])
|
||||
rescue ArgumentError
|
||||
options.delete("type")
|
||||
end
|
||||
end
|
||||
sort = -1
|
||||
if options.has_key?("sort")
|
||||
sort = 1 if options["sort"] == "asc"
|
||||
options.delete("sort")
|
||||
end
|
||||
@reports.find(options).to_a.map{|e| Report.new(e)}
|
||||
end
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ class ReportRoutes < Sinatra::Base
|
||||
|
||||
get "/all" do
|
||||
options = {}
|
||||
["project", "deploy_env", "type", "created_by", "date_from", "date_to"].each do |k|
|
||||
["project", "deploy_env", "type", "created_by", "date_from", "date_to", "sort"].each do |k|
|
||||
options[k] = params[k] unless params[k].nil?
|
||||
end
|
||||
json DevopsService.mongo.reports(options).map{|r| r.to_hash}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user