diff --git a/app/controllers/status_controller.rb b/app/controllers/status_controller.rb
index 5cfa8ceed..56474a952 100644
--- a/app/controllers/status_controller.rb
+++ b/app/controllers/status_controller.rb
@@ -8,7 +8,9 @@ class StatusController < ApplicationController
before_action :verify_admin, only: [:kill]
def index
- @statuses = SmokeDetector.includes(:statistics).order(Arel.sql('last_ping DESC')).all
+ @statuses = SmokeDetector.order(Arel.sql('last_ping DESC')).all
+ @scans = Statistic.where('created_at >= ?', 24.hours.ago).select(Arel.sql('smoke_detector_id, SUM(posts_scanned) as scans'))
+ .group(:smoke_detector_id)
end
def status_update
diff --git a/app/views/status/index.html.erb b/app/views/status/index.html.erb
index db14de622..af4ae60d0 100644
--- a/app/views/status/index.html.erb
+++ b/app/views/status/index.html.erb
@@ -2,11 +2,11 @@
-
Name | Scans Today | -Last Ping | +Last Ping | - <%= sd.statistics.where('created_at >= ?', 24.hours.ago).sum(:posts_scanned) %> + <%= @scans.select { |id, scans| id == sd.id }.try(:[], 0) || '(unavailable)' %> | <%= time_ago_in_words(sd.last_ping, include_seconds: true)%> ago |
---|