summaryrefslogtreecommitdiff
path: root/lib/report.rb
blob: 7c06d601d29f4c9b2b8ada7214890ef5c56f30c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Get a list of all possible reports to prediction models
# @param [Header] Accept one of text/uri-list,
# @return [text/uri-list] list of all prediction models
get "/api/report/?" do
  models = Model::Validation.all
  case @accept
  when "text/uri-list"
    uri_list = models.collect{|model| uri("/api/report/#{model.model_id}")}
    return uri_list.join("\n") + "\n"
  when "application/json"
    models = JSON.parse models.to_json
    list = []
    models.each{|m| list << uri("/api/report/#{m["_id"]["$oid"]}")}
    return list.to_json
  else
    halt 400, "Mime type #{@accept} is not supported."
  end
end

get "/api/report/:id/?" do
  case @accept
  when "application/xml"
    report = qmrf_report params[:id]
    return report.to_xml
  else
    halt 400, "Mime type #{@accept} is not supported."
  end

end