diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-07-25 22:50:42 +0200 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-07-25 22:52:21 +0200 |
commit | e508e4831a25367d101fe4a29423f298fa5609ca (patch) | |
tree | e897b23ece95f9ce9b0494067d5a4384a923a262 /sonar-server | |
parent | f996705eeffd9314b4b29ba053a94fef621f3948 (diff) | |
download | sonarqube-e508e4831a25367d101fe4a29423f298fa5609ca.tar.gz sonarqube-e508e4831a25367d101fe4a29423f298fa5609ca.zip |
SONAR-830 Sonar WS API return all elements when there aren't metric value
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb index dd852589a53..bfbef413a76 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/resources_controller.rb @@ -88,11 +88,11 @@ class Api::ResourcesController < Api::ApiController load_measures=true if params['metrics']!='true' - metrics=Metric.by_keys(params[:metrics].split(',')) - measures_conditions <<'project_measures.metric_id IN (:metrics)' + metrics = Metric.by_keys(params[:metrics].split(',')) + measures_conditions << 'project_measures.metric_id IN (:metrics)' measures_values[:metrics]=metrics.select{|m| m.id} if metrics.size==1 - measures_limit = [params[:limit].to_i,500].min if params[:limit] + measures_limit = (params[:limit] ? [params[:limit].to_i,500].min : 500) measures_order = "project_measures.value #{'DESC' if metrics.first.direction<0}" end end @@ -112,9 +112,10 @@ class Api::ResourcesController < Api::ApiController measures_by_sid[measure.snapshot_id]<<measure end - if measures_limit && !measures.empty? + if measures_limit snapshots_conditions << 'snapshots.id IN (:sids)' - snapshots_values[:sids]=measures_by_sid.keys + # Derby does not support empty lists, that's why a fake value is set + snapshots_values[:sids] = (measures_by_sid.empty? ? [-1] : measures_by_sid.keys) end # load coding rules |