trabajo-afectivo/lib/stats.rb

46 lines
755 B
Ruby
Raw Normal View History

2015-09-06 22:42:11 +00:00
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'stats_store'
class Stats
=begin
generate stats for user
Stats.generate
returns
result = true # if generation was successfully
=end
def self.generate
backends = [
Stats::TicketChannelDistribution,
Stats::TicketInProcess,
Stats::TicketLoadMeasure,
Stats::TicketEscalation,
Stats::TicketReopen,
]
users = User.of_role('Agent')
users.each {|user|
data = {}
backends.each {|backend|
data[backend.to_app_model] = backend.generate(user)
}
StatsStore.sync(
object: 'User',
o_id: user.id,
key: 'dashboard',
data: data,
)
}
true
end
end