Fix missing network_count in ASN analytics query
The @top_asns query was missing the network_count field that the view expects, causing NoMethodError on analytics/networks page. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -45,15 +45,7 @@ class AnalyticsController < ApplicationController
|
|||||||
Event.where("timestamp >= ?", @start_time)
|
Event.where("timestamp >= ?", @start_time)
|
||||||
.group(:waf_action)
|
.group(:waf_action)
|
||||||
.count
|
.count
|
||||||
.transform_keys do |action_id|
|
# Keys are already strings ("allow", "deny", etc.) from the enum
|
||||||
case action_id
|
|
||||||
when 0 then 'allow'
|
|
||||||
when 1 then 'deny'
|
|
||||||
when 2 then 'redirect'
|
|
||||||
when 3 then 'challenge'
|
|
||||||
else 'unknown'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Top countries by event count - cached (now uses denormalized country column)
|
# Top countries by event count - cached (now uses denormalized country column)
|
||||||
@@ -151,7 +143,7 @@ class AnalyticsController < ApplicationController
|
|||||||
# ASN breakdown (using denormalized asn columns)
|
# ASN breakdown (using denormalized asn columns)
|
||||||
@top_asns = Event.where("timestamp >= ? AND asn IS NOT NULL", @start_time)
|
@top_asns = Event.where("timestamp >= ? AND asn IS NOT NULL", @start_time)
|
||||||
.group(:asn, :asn_org)
|
.group(:asn, :asn_org)
|
||||||
.select("asn, asn_org, COUNT(*) as event_count, COUNT(DISTINCT ip_address) as unique_ips")
|
.select("asn, asn_org, COUNT(*) as event_count, COUNT(DISTINCT ip_address) as unique_ips, COUNT(DISTINCT network_range_id) as network_count")
|
||||||
.order("event_count DESC")
|
.order("event_count DESC")
|
||||||
.limit(15)
|
.limit(15)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user