Class: TrakFlow::Mcp::Resources::TaskNext

Inherits:
BaseResource
  • Object
show all
Defined in:
lib/trak_flow/mcp/resources/task_next.rb

Instance Method Summary collapse

Methods inherited from BaseResource

with_database

Instance Method Details

#contentObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/trak_flow/mcp/resources/task_next.rb', line 12

def content
  self.class.with_database do |db|
    tasks = db.ready_tasks
    next_task = tasks.first

    if next_task
      labels = db.find_labels(next_task.id)
      result = { task: next_task.to_h, labels: labels.map(&:name) }
    else
      result = { task: nil, message: "No ready tasks found" }
    end

    Oj.dump(result, mode: :compat, indent: 2)
  end
end