diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2012-01-30 17:17:16 +0100 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2012-01-30 17:17:16 +0100 |
commit | aece758f85682f49dfc02ef5cae2729c680dcc57 (patch) | |
tree | 69714c0563d6ff9c55baf4be2caa6bb99c42cc1b /sonar-server | |
parent | 8f0074d7657f2a12ef4c0a086814b19076d837ca (diff) | |
download | sonarqube-aece758f85682f49dfc02ef5cae2729c680dcc57.tar.gz sonarqube-aece758f85682f49dfc02ef5cae2729c680dcc57.zip |
SONAR-3091 Improve the "Events" widget
=> The "Events" widget should not display events on snapshots which
are about to be deleted
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb index 7273a65e47d..a7f5dfe62f4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb @@ -138,14 +138,25 @@ class ProjectController < ApplicationController def events - @categories=EventCategory.categories(true) - @snapshot=Snapshot.find(params[:id]) - @category=params[:category] - conditions={:resource_id => @snapshot.project_id} - conditions[:category]=@category unless @category.blank? + @categories = EventCategory.categories(true) + @snapshot = Snapshot.find(params[:id]) + @category = params[:category] + + conditions = "resource_id=:resource_id" + values = {:resource_id => @snapshot.project_id} + unless @category.blank? + conditions << " AND category=:category" + values[:category] = @category + end + # in order to not display events linked to deleted snapshot, we build the SQL request with 'NOT IN' as most of the time, there won't be unprocessed snapshots + snapshots_to_be_deleted = Snapshot.find(:all, :conditions => ["status='U' AND project_id=?", @snapshot.project_id]) + unless snapshots_to_be_deleted.empty? + conditions << " AND snapshot_id NOT IN (:sids)" + values[:sids] = snapshots_to_be_deleted.map {|s| s.id.to_s} + end category_names=@categories.map { |cat| cat.name } - @events=Event.find(:all, :conditions => conditions, :order => 'event_date desc').select do |event| + @events=Event.find(:all, :conditions => [conditions, values], :order => 'event_date desc').select do |event| category_names.include?(event.category) end render :action => 'events', :layout => !request.xhr? |