]> source.dussan.org Git - sonarqube.git/commitdiff
Fix filter in the violations viewer
authorSimon Brandhof <simon.brandhof@gmail.com>
Wed, 6 Jun 2012 13:31:53 +0000 (15:31 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Wed, 6 Jun 2012 13:32:11 +0000 (15:32 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb

index 549af613a80c368c366790cfbf52cecb38e61cf0..3faaa37dec92648fe4b9568b27e160d7546ad831 100644 (file)
@@ -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
index 72a1d405f7286c290191105e4bda6dfe3a8670fc..ed69de10094003cd87a647316d54209adc40b76a 100644 (file)
@@ -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