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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Refactor debounce impl to be more readable.
Pavel Balashou3450752a3675
diff --git a/modules/storages/app/workers/storages/manage_nextcloud_integration_events_job.rb b/modules/storages/app/workers/storages/manage_nextcloud_integration_events_job.rbindex 5790b60b845..6e7ae17a59d 100644--- a/modules/storages/app/workers/storages/manage_nextcloud_integration_events_job.rb+++ b/modules/storages/app/workers/storages/manage_nextcloud_integration_events_job.rb@@ -36,15 +36,22 @@ module Storagesqueue_with_priority :above_normal- def self.debounce- last_current_thread_debounce_happend_at = RequestStore.store[KEY]- if last_current_thread_debounce_happend_at.blank? ||- Time.current > (last_current_thread_debounce_happend_at + SINGLE_THREAD_DEBOUNCE_TIME)- Rails.cache.fetch(KEY, expires_in: MULTI_THREAD_DEBOUNCE_TIME) do- set(wait: MULTI_THREAD_DEBOUNCE_TIME).perform_later- RequestStore.store[KEY] = Time.current+ class << self+ def debounce+ unless debounce_happend_in_current_thread_recently?+ Rails.cache.fetch(KEY, expires_in: MULTI_THREAD_DEBOUNCE_TIME) do+ set(wait: MULTI_THREAD_DEBOUNCE_TIME).perform_later+ RequestStore.store[KEY] = Time.current+ endendend++ private++ def debounce_happend_in_current_thread_recently?+ timestamp = RequestStore.store[KEY]+ timestamp.present? && (timestamp + SINGLE_THREAD_DEBOUNCE_TIME) > Time.current+ endenddef perform