aboutsummaryrefslogtreecommitdiffstats
path: root/collecstats.rb
blob: efe6055c7fb312a195b4a7804e4d2fda498557f3 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require 'date'

packages = {}

def file_time(file_name)
  File::Stat.new(file_name).mtime
end

Dir.glob("/var/lib/schedbot/uploads/todo/cauldron/core/release/*umeabo*.info").each{|f|
  # f = "/var/lib/schedbot/uploads/todo/cauldron/core/release/20250628173238.umeabot.duvel.498607_@2220249:rust-pathfinder_simd-0.5.2-0.2.mga10.src.rpm.info"
  prefix = f.sub(/.*\/([^\/]*\.umeabot[^_]*)_.*/, "\\1")
  path = f.sub(/(.*)\/[^\/]*\.umeabot.*/, "\\1")
  srpm = f.sub(/.*:(.*)\.info/, "\\1")

  p = {}
  done_path = path.sub(/\/todo\//, "/done/")
  p['submit_time'] = DateTime.strptime(f.sub(/.*\/([^\/]*)\.umeabot.*/, "\\1"), "%Y%m%d%H%M%S").to_time
  upload_file = "#{done_path}/#{prefix}.upload"
  if File.exists?(upload_file) then
    p['upload_time'] = file_time(upload_file)
  else
    next
  end
  noarch = File.exists?("#{done_path}/#{prefix}_noarch.done")
  Dir.glob("#{done_path}/#{prefix}/*/build.*.log").each{|l|
    # rpm_qa.i686.0.20250628173325.log
    s = File.basename(l).split(".")
    if noarch then
      arch = "noarch"
    else
      arch = s[1]
    end
    start_time = DateTime.strptime(s[3], "%Y%m%d%H%M%S").to_time
    end_time = file_time(l)
    p["builds"] ||= {}
    p["builds"][arch] = {
      'build_start' => start_time,
      'build_end' => end_time,
      'build_secs' => (end_time - start_time).to_i,
    }
  }
  packages[srpm] = p
}

puts "package,arch,submit_time,upload_time,build_start_time,build_end_time,build_secs"
packages.keys.sort.each{|pname|
  pkg = packages[pname]
  pkg["builds"].keys.sort.each{|b|
    t = pkg["builds"][b]
    puts "#{pname},#{b},#{pkg["submit_time"]},#{pkg["upload_time"]},#{t["build_start"]},#{t["build_end"]},#{t["build_secs"]}"
  }
}