blob: 2f474199a22a7a5cb4f47319713ce8114737ca31 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
module Oxidized
class Node
class Stats
MAX_STAT = 10
# @param [Job] job job whose information add to stats
# @return [void]
def add job
status = job.stats.dup
stat = {
:start => job.start.dup,
:end => job.end.dup,
:time => job.time.dup,
}
@stats[status] ||= []
@stats[status].shift if @stats[status].size > MAX_STAT
@stats[status].push stat
end
# @param [Symbol] status stats for specific status
# @return [Hash,Array] Hash of stats for every status or Array of stats for specific status
def get status=nil
status ? @stats[status] : @stats
end
private
def initialize
@stats = {}
end
end
end
end
|