diff options
author | Rhenium <rhenium@rhe.jp> | 2013-07-28 19:07:28 +0900 |
---|---|---|
committer | Rhenium <rhenium@rhe.jp> | 2013-07-28 19:07:28 +0900 |
commit | 0779e11a3bdaa670f8a9c130764de866f63764b7 (patch) | |
tree | 8c828a74c886257fc69d38675cd1b60546c6035b | |
parent | 2e552090d8f66d71403abfe21a879a9ff0754e4a (diff) | |
download | aclog-0779e11a3bdaa670f8a9c130764de866f63764b7.tar.gz |
refactor receiver: create Account.set_of_collector(collector_id)
-rw-r--r-- | app/models/account.rb | 4 | ||||
-rw-r--r-- | lib/aclog/receiver/collector_connection.rb | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index b3bcb4d..e43c145 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -17,6 +17,10 @@ class Account < ActiveRecord::Base account end + def self.set_of_collector(collector_id) + self.active.where("id % ? = ?", Settings.collector.count, collector_id) + end + def notification?; self.notification end def private?; self.private end def active?; self.status == Account::ACTIVE end diff --git a/lib/aclog/receiver/collector_connection.rb b/lib/aclog/receiver/collector_connection.rb index 0ee8e6c..f5ec736 100644 --- a/lib/aclog/receiver/collector_connection.rb +++ b/lib/aclog/receiver/collector_connection.rb @@ -113,7 +113,7 @@ module Aclog Rails.logger.info("Connected(#{@worker_number})") send_object(type: "ok", message: "Connected") - Account.where("id % ? = ?", Settings.collector.count, @worker_number).each do |account| + Account.set_of_collector(@worker_number).each do |account| send_account(account) end end |