Class: Collavre::Task

Inherits:
ApplicationRecord show all
Defined in:
app/models/collavre/task.rb

Class Method Summary collapse

Class Method Details

.duplicate_running_for_comment?(agent_id, comment_id) ⇒ Boolean

Check if agent already has a running task triggered by the same comment

Returns:

  • (Boolean)


29
30
31
32
33
34
35
# File 'app/models/collavre/task.rb', line 29

def self.duplicate_running_for_comment?(agent_id, comment_id)
  where(agent_id: agent_id, status: "running", trigger_event_name: "comment_created")
    .find_each do |task|
    return true if task.trigger_event_payload&.dig("comment", "id").to_s == comment_id.to_s
  end
  false
end