forked from cncf/gitdm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompare_results.rb
79 lines (67 loc) · 1.98 KB
/
compare_results.rb
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require 'csv'
require 'pry'
require './email_code'
def compare_results(f1, f2)
# email,company,final_company,date_from,date_to
map1 = {}
com1 = {}
CSV.foreach(f1, headers: true) do |row|
h = row.to_h
e = email_encode(h['email'])
fc = h['final_company']
map1[e] = fc
com1[fc] = [] unless com1.key?(fc)
com1[fc] << e
end
map2 = {}
com2 = {}
CSV.foreach(f2, headers: true) do |row|
h = row.to_h
e = email_encode(h['email'])
fc = h['final_company']
map2[e] = fc
com2[fc] = [] unless com2.key?(fc)
com2[fc] << e
end
n1 = map1.keys.length
n2 = map2.keys.length
puts "CNCF mapping: #{n1} developers, Facade mapping: #{n2} developers"
n1 = (com1.keys - ['(Unknown']).length
n2 = (com2.keys - ['(Unknown)']).length
puts "CNCF mapping: #{n1} employers, Facade mapping: #{n2} employers"
n1 = com1['(Unknown)'].length
n2 = com2['(Unknown)'].length
puts "CNCF mapping: #{n1} unknown developers, Facade mapping: #{n2} unnown developers"
n1 = 0
(com1.keys - ['(Unknown)']).each { |k| n1 += com1[k].length }
n2 = 0
(com2.keys - ['(Unknown)']).each { |k| n2 += com2[k].length }
puts "CNCF mapping: #{n1} mapped developers, Facade mapping: #{n2} mapped developers"
no = same = other = 0
map2.each do |email, company|
company2 = map1[email]
no += 1 unless company2
if company == company2
same += 1
elsif company2
other += 1
end
end
puts "From Facade mapping: #{no} emails not found, #{other} emails other, #{same} emails match CNCF mapping"
no = same = other = 0
map1.each do |email, company|
company2 = map2[email]
no += 1 unless company2
if company == company2
same += 1
elsif company2
other += 1
end
end
puts "From CNCF mapping: #{no} emails not found, #{other} emails other, #{same} emails match Facade mapping"
end
if ARGV.size < 2
puts "Missing arguments: stats/all_changesets.csv facade_kubernetes.csv"
exit(1)
end
compare_results(ARGV[0], ARGV[1])