25 lines
904 B
Ruby
25 lines
904 B
Ruby
# frozen_string_literal: true
|
|
|
|
class EventsController < ApplicationController
|
|
def index
|
|
@events = Event.order(timestamp: :desc)
|
|
Rails.logger.debug "Found #{@events.count} total events"
|
|
Rails.logger.debug "Action: #{params[:waf_action]}"
|
|
|
|
# Apply filters
|
|
@events = @events.by_ip(params[:ip]) if params[:ip].present?
|
|
@events = @events.by_waf_action(params[:waf_action]) if params[:waf_action].present?
|
|
@events = @events.where(country_code: params[:country]) if params[:country].present?
|
|
|
|
Rails.logger.debug "Events count after filtering: #{@events.count}"
|
|
|
|
# Debug info
|
|
Rails.logger.debug "Events count before pagination: #{@events.count}"
|
|
|
|
# Paginate
|
|
@pagy, @events = pagy(@events, items: 50)
|
|
|
|
Rails.logger.debug "Events count after pagination: #{@events.count}"
|
|
Rails.logger.debug "Pagy info: #{@pagy.count} total, #{@pagy.pages} pages"
|
|
end
|
|
end |