Class: Flare::JobsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/flare/jobs_controller.rb

Constant Summary collapse

PER_PAGE =
50

Instance Method Summary collapse

Instance Method Details

#indexObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/flare/jobs_controller.rb', line 11

def index
  @offset = params[:offset].to_i
  filter_params = {
    name: params[:name].presence
  }
  # Fetch one extra to know if there's a next page
  jobs = Flare.storage.list_jobs(**filter_params, limit: PER_PAGE + 1, offset: @offset)
  @total_count = Flare.storage.count_jobs(**filter_params)
  @has_next = jobs.size > PER_PAGE
  @jobs = jobs.first(PER_PAGE)
  @has_prev = @offset > 0
end

#showObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/flare/jobs_controller.rb', line 24

def show
  @job = Flare.storage.find_job(params[:id])

  if @job.blank?
    redirect_to jobs_path, alert: "Job not found"
    return
  end

  @spans = Flare.storage.spans_for_trace(params[:id])

  # Find the root span (the job itself) with full properties
  @root_span = @spans.find { |s| s[:parent_span_id] == Flare::MISSING_PARENT_ID }

  # Child spans (everything except the root)
  @child_spans = @spans.reject { |s| s[:parent_span_id] == Flare::MISSING_PARENT_ID }
end