Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Made ManagenextcloudIntegrationJob emit health events

Andreas Pfohl7a0572a85621
diff --git a/modules/storages/app/workers/storages/manage_nextcloud_integration_job.rb b/modules/storages/app/workers/storages/manage_nextcloud_integration_job.rb
index e9616253014..93484254b98 100644
--- a/modules/storages/app/workers/storages/manage_nextcloud_integration_job.rb
+++ b/modules/storages/app/workers/storages/manage_nextcloud_integration_job.rb
@@ -38,14 +38,14 @@ module Storages
key: "ManageNextcloudIntegrationJob"
)
SINGLE_THREAD_DEBOUNCE_TIME = 4.seconds.freeze
- KEY = :manage_nextcloud_integration_job_debounce_happend_at
- CRON_JOB_KEY = :'Storages::ManageNextcloudIntegrationJob'
+ KEY = :manage_nextcloud_integration_job_debounce_happened_at
+ CRON_JOB_KEY = :"Storages::ManageNextcloudIntegrationJob"
queue_with_priority :above_normal
class << self
def debounce
- if debounce_happend_in_current_thread_recently?
+ if debounce_happened_in_current_thread_recently?
false
else
# TODO:
@@ -73,7 +73,7 @@ module Storages
private
- def debounce_happend_in_current_thread_recently?
+ def debounce_happened_in_current_thread_recently?
timestamp = RequestStore.store[KEY]
timestamp.present? && (timestamp + SINGLE_THREAD_DEBOUNCE_TIME) > Time.current
end
@@ -85,8 +85,10 @@ module Storages
result = service_for(storage).call(storage)
result.match(
- on_success: ->(_) { storage.mark_as_healthy },
- on_failure: ->(errors) { storage.mark_as_unhealthy(reason: errors.to_s) }
+ on_success: ->(_) { OpenProject::Notifications.send(OpenProject::Events::STORAGE_TURNED_HEALTHY, storage:) },
+ on_failure: ->(errors) do
+ OpenProject::Notifications.send(OpenProject::Events::STORAGE_TURNED_UNHEALTHY, storage:, reason: errors.to_s)
+ end
)
end
end
@@ -104,7 +106,7 @@ module Storages
return NextcloudGroupFolderPropertiesSyncService if storage.provider_type_nextcloud?
return OneDriveManagedFolderSyncService if storage.provider_type_one_drive?
- raise 'Unknown Storage'
+ raise "Unknown Storage"
end
end
end