From: Simon Brandhof Date: Wed, 6 Jun 2012 13:31:53 +0000 (+0200) Subject: Fix filter in the violations viewer X-Git-Tag: 3.1~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=30f7fbef30928d8914df2420021254ad3b3481c4;p=sonarqube.git Fix filter in the violations viewer --- diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb index 549af613a80..3faaa37dec9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb @@ -323,6 +323,9 @@ class ResourceController < ApplicationController metric = Metric.by_id(params[:metric]) if metric && (metric.name=='active_reviews' || metric.name=='unassigned_reviews' || metric.name=='unplanned_reviews' || metric.name=='false_positive_reviews'|| metric.name=='unreviewed_violations' || metric.name=='new_unreviewed_violations') rule_param = metric.name.gsub(/new_/, '') + + # hack to select the correct option in the rule filter select-box + params[:rule] = rule_param end end @@ -352,6 +355,7 @@ class ResourceController < ApplicationController end end + if @period date=@snapshot.period_datetime(@period) if date diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb index 72a1d405f72..ed69de10094 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb @@ -203,13 +203,13 @@ class RuleFailure < ActiveRecord::Base if options.has_key? :review_statuses statuses = options[:review_statuses] - if !statuses.empty? + unless statuses.empty? if statuses.include? nil if statuses.size==1 # only nil : unreviewed violations - conditions << 'not exists(select id from reviews where rule_failure_permanent_id=rule_failures.id)' + conditions << 'not exists(select id from reviews where rule_failure_permanent_id=rule_failures.permanent_id)' else - conditions << '(reviews.status in (?) or not exists(select id from reviews where rule_failure_permanent_id=rule_failures.id))' + conditions << '(reviews.status in (?) or not exists(select id from reviews where rule_failure_permanent_id=rule_failures.permanent_id))' values << options[:review_statuses].compact end else @@ -225,7 +225,7 @@ class RuleFailure < ActiveRecord::Base conditions << 'reviews.assignee_id=?' values << review_assignee_id.to_i else - conditions << '(reviews.assignee_id is null or not exists(select id from reviews where rule_failure_permanent_id=rule_failures.id))' + conditions << '(reviews.assignee_id is null or not exists(select id from reviews where rule_failure_permanent_id=rule_failures.permanent_id))' end end