Class: Flare::RequestsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Flare::RequestsController
- Defined in:
- app/controllers/flare/requests_controller.rb
Constant Summary collapse
- PER_PAGE =
50
Instance Method Summary collapse
Instance Method Details
#clear ⇒ Object
44 45 46 47 |
# File 'app/controllers/flare/requests_controller.rb', line 44 def clear Flare.storage.clear_all redirect_to root_path end |
#index ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/flare/requests_controller.rb', line 11 def index @offset = params[:offset].to_i filter_params = { status: params[:status].presence, method: params[:method].presence, name: params[:name].presence, origin: current_origin } # Fetch one extra to know if there's a next page requests = Flare.storage.list_requests(**filter_params, limit: PER_PAGE + 1, offset: @offset) @total_count = Flare.storage.count_requests(**filter_params) @has_next = requests.size > PER_PAGE @requests = requests.first(PER_PAGE) @has_prev = @offset > 0 end |
#show ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/flare/requests_controller.rb', line 27 def show @request = Flare.storage.find_request(params[:id]) if @request.blank? redirect_to requests_path, alert: "Request not found" return end @spans = Flare.storage.spans_for_trace(params[:id]) # Find the root span (the request 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 |