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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/subcommands/series.rb', line 5
def ls(search=nil)
if search.nil?
series = ::Series.all.order(options[:order].to_sym => :desc)
else
log = Log.find_by_name(search)
if log
series = ::Series.where(log: log).order(options[:order].to_sym => :desc)
else
puts ""
say "Could not find #{search}!", :red
puts ""
exit
end
end
series_stats = Statistics.new
table = [['#', 'log', 'start', 'end', 'hours']] series.each do |s|
next if s.log_id.blank?
start = s.start
finish = s.end
series_stats << timer = start.difference(finish || Time.now)
start = time_display(start) if start
finish = time_display(finish) if finish
name = ''
name = s.log.name if !s.log.name.empty?
table << [s.id,
name || '',
start,
finish || "active",
(timer/3600).round(2).to_s] end
puts ''
print_table table
puts ''
say [series.count.to_s, "series out of", ::Series.count].join(' '), :cyan
say [(series_stats.mean/3600).round(2), "hours avg"].join(' '), :cyan
end
|