From 30f7fbef30928d8914df2420021254ad3b3481c4 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 6 Jun 2012 15:31:53 +0200 Subject: [PATCH] Fix filter in the violations viewer --- .../webapp/WEB-INF/app/controllers/resource_controller.rb | 4 ++++ .../src/main/webapp/WEB-INF/app/models/rule_failure.rb | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) 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 -- 2.39.5