Class: Profiler::Api::ProfilesController

Inherits:
Profiler::ApplicationController show all
Defined in:
app/controllers/profiler/api/profiles_controller.rb

Instance Method Summary collapse

Instance Method Details

#clearObject



34
35
36
37
# File 'app/controllers/profiler/api/profiles_controller.rb', line 34

def clear
  Profiler.storage.clear(type: "http")
  head :no_content
end

#destroyObject



26
27
28
29
30
31
32
# File 'app/controllers/profiler/api/profiles_controller.rb', line 26

def destroy
  profile = Profiler.storage.load(params[:id])
  return render json: { error: "Profile not found" }, status: :not_found unless profile

  Profiler.storage.delete(params[:id])
  head :no_content
end

#indexObject



8
9
10
11
# File 'app/controllers/profiler/api/profiles_controller.rb', line 8

def index
  profiles = Profiler.storage.list(limit: params[:limit] || 50, offset: params[:offset] || 0)
  render json: profiles.map(&:to_h)
end

#showObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/profiler/api/profiles_controller.rb', line 13

def show
  profile = Profiler.storage.load(params[:id])

  unless profile
    return render json: { error: "Profile not found" }, status: :not_found
  end

  # Recalculate AJAX collector data (since AJAX requests happen after page load)
  recalculate_ajax_data(profile)

  render json: profile.to_h
end