lib/rocket_job/server.rb in rocketjob-3.3.1 vs lib/rocket_job/server.rb in rocketjob-3.3.2
- old
+ new
@@ -139,17 +139,18 @@
# Example no servers active:
# RocketJob::Server.counts_by_state
# # => {}
def self.counts_by_state
counts = {}
- collection.aggregate([
- {
- '$group' => {
- _id: '$state',
- count: {'$sum' => 1}
+ collection.aggregate(
+ [
+ {
+ '$group' => {
+ _id: '$state',
+ count: {'$sum' => 1}
+ }
}
- }
- ]
+ ]
).each do |result|
counts[result['_id'].to_sym] = result['count']
end
counts
end