Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/lib/worker/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Process
PruneWebhookRequestsScheduledTask,
SendNotificationsScheduledTask,
TidyQueuedMessagesTask,
TidyWebhookRequestsTask,
].freeze

# @param [Integer] thread_count The number of worker threads to run in this process
Expand Down
2 changes: 2 additions & 0 deletions app/models/webhook_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class WebhookRequest < ApplicationRecord

serialize :payload, type: Hash

scope :with_stale_lock, -> { where("locked_at IS NOT NULL AND locked_at < ?", 1.hour.ago) }

class << self

def trigger(server, event, payload = {})
Expand Down
16 changes: 16 additions & 0 deletions app/scheduled_tasks/tidy_webhook_requests_task.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

class TidyWebhookRequestsTask < ApplicationScheduledTask

def call
WebhookRequest.with_stale_lock.find_each do |request|
logger.info "unlocking stale webhook request #{request.id} (locked at #{request.locked_at} by #{request.locked_by})"
request.unlock
end
end

def self.next_run_after
quarter_to_each_hour
end

end