From f489546852c58d8215af491a971fdde92f9bd4a4 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Fri, 6 Jul 2012 12:38:04 +0200 Subject: [PATCH] SONAR-2614 Add time spent on deletion --- .../src/main/resources/org/sonar/l10n/core.properties | 1 + .../WEB-INF/app/models/resource_deletion_manager.rb | 8 ++++++++ .../bulk_deletion/_pending_deletions_screen.html.erb | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index 2633daf30ee..d1fb5fb7af7 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -1280,6 +1280,7 @@ bulk_deletion.deletion_manager.no_resource_to_delete=No resource to delete. bulk_deletion.deletion_manager.currently_deleting_x_out_of_x=Currently deleting resources... ({0} out of {1}) bulk_deletion.deletion_manager.deletion_completed=Resource deletion completed. bulk_deletion.deletion_manager.however_failures_occurred=However, some failures occurred. +bulk_deletion.started_since_x=Started {0} #------------------------------------------------------------------------------ diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/resource_deletion_manager.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/resource_deletion_manager.rb index dbdcd73a348..6ae5e129034 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/resource_deletion_manager.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/resource_deletion_manager.rb @@ -42,6 +42,9 @@ class ResourceDeletionManager # list of resources that could not be deleted because of a problem @failed_deletions + # the time when the deletion was started + @start_time + def initialize reinit() end @@ -68,6 +71,10 @@ class ResourceDeletionManager @failed_deletions end + def deletion_start_time + @start_time + end + def delete_resources(resource_ids=[]) # Use an exclusive block of code to ensure that only 1 thread will be able to proceed with the deletion can_start_deletion = false @@ -86,6 +93,7 @@ class ResourceDeletionManager @message = Api::Utils.message('bulk_deletion.deletion_manager.no_resource_to_delete') else java_facade = Java::OrgSonarServerUi::JRubyFacade.getInstance() + @start_time = Time.now # launch the deletion resource_ids.each_with_index do |resource_id, index| resource = Project.find(:first, :conditions => {:id => resource_id.to_i}) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/bulk_deletion/_pending_deletions_screen.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/bulk_deletion/_pending_deletions_screen.html.erb index 27895ebe7dc..ab311285ab1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/bulk_deletion/_pending_deletions_screen.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/bulk_deletion/_pending_deletions_screen.html.erb @@ -2,6 +2,7 @@ deletion_manager = ResourceDeletionManager.instance pending_deletions = deletion_manager.currently_deleting_resources? failed_deletions = deletion_manager.failed_deletions + start_time = deletion_manager.deletion_start_time %> <% if pending_deletions %> @@ -18,6 +19,9 @@ <%= deletion_manager.message -%>

+ <%= message('bulk_deletion.started_since_x', :params => distance_of_time_in_words(start_time, Time.now) ) -%> (<%= l start_time -%>) +
+
<% if !pending_deletions && !failed_deletions.empty? %>

-- 2.39.5