diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-06-21 17:48:12 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-06-27 10:54:57 +0200 |
commit | fba02ff24c49e30a36ea7da8b4558fb622a379d7 (patch) | |
tree | 6fcfdb5cec747f40b5ad69dba502787a5af8cc65 /server/sonar-web | |
parent | 4f32dd7477e75b543cc937cd3453d0fff19a6d0d (diff) | |
download | sonarqube-fba02ff24c49e30a36ea7da8b4558fb622a379d7.tar.gz sonarqube-fba02ff24c49e30a36ea7da8b4558fb622a379d7.zip |
SONAR-7803 creates events only on PROJECTS
Diffstat (limited to 'server/sonar-web')
-rw-r--r-- | server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb index 62de84287c3..5034d1fd938 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/project_controller.rb @@ -294,25 +294,20 @@ class ProjectController < ApplicationController if Event.already_exists(snapshot.id, params[:version_name], EventCategory::KEY_VERSION) flash[:error] = message('project_history.version_already_exists', :params => h(params[:version_name])) else - snapshots = find_project_snapshots(snapshot.id) - # We update all the related snapshots to have a version attribute in sync with the new name - snapshots.each do |snapshot| - snapshot.version = params[:version_name] - snapshot.save! - end - # And then we update/create the event on each snapshot + # We update the snapshot to have a version attribute in sync with the new name + snapshot.version = params[:version_name] + snapshot.save! + # And then we update/create the event on the snapshot if snapshot.event(EventCategory::KEY_VERSION) - # This is an update: we update all the related events + # This is an update: we update the event Event.update_all({:name => params[:version_name]}, - ["category = ? AND snapshot_id IN (?)", EventCategory::KEY_VERSION, snapshots.map { |s| s.id }]) + ["category = ? AND snapshot_id = ?", EventCategory::KEY_VERSION, snapshot.id]) flash[:notice] = message('project_history.version_updated', :params => h(params[:version_name])) else - # We create an event for every concerned snapshot - snapshots.each do |snapshot| - event = Event.create!(:name => params[:version_name], :snapshot => snapshot, - :component_uuid => snapshot.project.uuid, :category => EventCategory::KEY_VERSION, - :event_date => snapshot.created_at) - end + # We create an event on the snapshot + event = Event.create!(:name => params[:version_name], :snapshot => snapshot, + :component_uuid => snapshot.project.uuid, :category => EventCategory::KEY_VERSION, + :event_date => snapshot.created_at) flash[:notice] = message('project_history.version_created', :params => h(params[:version_name])) end end |