trabajo-afectivo/lib/stats.rb

47 lines
782 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|
2015-09-06 23:52:54 +00:00
next if user.id == 1
2015-09-06 22:42:11 +00:00
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