-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_commit_interval.rb
More file actions
49 lines (40 loc) · 1.26 KB
/
set_commit_interval.rb
File metadata and controls
49 lines (40 loc) · 1.26 KB
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
require "rubygems"
require "sequel"
DB = Sequel.connect(:adapter => 'mysql2',:user => 'researcher', :password => "b3SxvkYbGJKe", :host => "127.0.0.1", :port=> "8889" , :database => "quality_ratings")
=begin
#get all repositories
repo = DB[:repository]
repo.each do |r|
commits = DB[:commit].where(:repository_id=>r[:id]).order(:short_date)
last_date = nil
commits.each do |c|
c_date = c[:short_date]
if last_date == nil
days = 0
else
days = (c_date - last_date).to_i
end
com = DB[:commit].where(:repository_id=>r[:id],:id => c[:id])
com.update(:interval => days)
last_date = c_date
end
end
=end
repo = DB[:repository]
repo.each do |r|
vs = DB[:version_details].where(:repository_id=>r[:id]).order(:details_appDetails_uploadDate_datetime)
vs.each do |v|
commits = DB[:commit].where(:version_id => v[:id],:repository_id=>r[:id]).order(:short_date)
commit_count = 0
total_days = 0
commits.each do |c|
if(c[:interval]>0)
total_days = total_days + c[:interval]
commit_count = commit_count+1
end
end
avg = (commit_count == 0) ? 0 : total_days/commit_count
ver = DB[:version_details].where(:id=>v[:id])
ver.update(:avg_commit_days => avg)
end
end