aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrhenium <rhenium@rhe.jp>2014-09-03 06:47:28 +0900
committerrhenium <rhenium@rhe.jp>2014-09-03 06:47:28 +0900
commitc1a9ac709f55ec0f971c8ad250af3dbe227bf549 (patch)
tree04648f2ff1cc9c69ca1ac91c48bea66294ee6e11
parentee28129beffe59865b444e0e6b905b0caf996554 (diff)
downloadaclog-c1a9ac709f55ec0f971c8ad250af3dbe227bf549.tar.gz
web: about#status: refactor
-rw-r--r--app/controllers/about_controller.rb4
-rw-r--r--app/models/account.rb6
-rw-r--r--app/views/about/status.html.haml10
-rw-r--r--lib/collector/control_server.rb3
4 files changed, 13 insertions, 10 deletions
diff --git a/app/controllers/about_controller.rb b/app/controllers/about_controller.rb
index bd58998..72b767f 100644
--- a/app/controllers/about_controller.rb
+++ b/app/controllers/about_controller.rb
@@ -5,10 +5,6 @@ class AboutController < ApplicationController
def status
@worker_status = WorkerManager.status
-
- if logged_in?
- @your_node_number = current_user.account.id % Settings.collector.nodes_count
- end
rescue
end
end
diff --git a/app/models/account.rb b/app/models/account.rb
index 7631160..b7cd690 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -65,4 +65,10 @@ class Account < ActiveRecord::Base
Set.new client.friend_ids
end
end
+
+ # Returns the worker id collecting tweets for this account.
+ # @return [Integer]
+ def worker_number
+ id % Settings.collector.nodes_count
+ end
end
diff --git a/app/views/about/status.html.haml b/app/views/about/status.html.haml
index 188ed87..65ec549 100644
--- a/app/views/about/status.html.haml
+++ b/app/views/about/status.html.haml
@@ -6,23 +6,23 @@
%table.table
%thead
%tr
- %th Group
+ %th Worker ID
%th Status
%th Uptime
%tbody
- - @worker_status[:active_node_statuses].each_with_index do |node, i|
+ - @worker_status[:active_node_statuses].each do |node|
- if node
%tr
- %td= i
+ %td ##{node.connection_id}
%td Running
%td= "#{(Time.now - node[:activated_time]).to_i / 60} minutes"
- else
%tr.danger
- %td= i
+ %td -
%td Down
%td -
- if logged_in?
- %p Your group is #{@your_node_number}.
+ %p Worker ##{@worker_status[:active_node_statuses][current_user.account.worker_number].connection_id} is assigned to your account.
- else
.alert.alert-danger
%strong Couldn't communicate with the collector service.
diff --git a/lib/collector/control_server.rb b/lib/collector/control_server.rb
index 5afb2b2..3889817 100644
--- a/lib/collector/control_server.rb
+++ b/lib/collector/control_server.rb
@@ -12,7 +12,8 @@ module Collector
active_node_statuses = Settings.collector.nodes_count.times.map do |number|
node = NodeManager.active_connections[number]
if node
- { activated_time: node.activated_time }
+ { activated_time: node.activated_time,
+ connection_id: node.connection_id }
else
nil
end