parent
5fe4e9e813
commit
a68392fd24
|
@ -173,14 +173,18 @@ class Issue < ActiveRecord::Base
|
|||
|
||||
# 创建issue的时候,issues_count加1
|
||||
def add_issues_count
|
||||
issue_count = self.project.issues_count + 1
|
||||
self.project.update_attribute(:issues_count, issue_count)
|
||||
unless self.project.project_score.nil?
|
||||
issue_count = self.project.project_score.issue_num + 1
|
||||
self.project.project_score.update_attribute(:issue_num, issue_count)
|
||||
end
|
||||
end
|
||||
|
||||
# 删除issue的时候,issues_count减1
|
||||
def decrease_issues_count
|
||||
issue_count = self.project.issues_count - 1
|
||||
self.project.update_attribute(:issues_count, issue_count)
|
||||
unless self.project.project_score.nil?
|
||||
issue_count = self.project.project_score.issue_num - 1
|
||||
self.project.project_score.update_attribute(:issue_num, issue_count)
|
||||
end
|
||||
end
|
||||
|
||||
# 更新缺陷
|
||||
|
|
|
@ -5,6 +5,10 @@ class UpdateProjectScore < ActiveRecord::Migration
|
|||
for i in 1 ... project_count do i
|
||||
Project.page(i).per(30).each do |project|
|
||||
puts project.id
|
||||
if ProjectScore.where("project_id=?", project.id).first.nil?
|
||||
puts "create project ==>#{project.id}"
|
||||
ProjectScore.create(:project_id => @project.id, :score => false)
|
||||
end
|
||||
unless project.project_score.nil?
|
||||
# update boards
|
||||
unless project.boards.first.nil?
|
||||
|
@ -40,6 +44,17 @@ class UpdateProjectScore < ActiveRecord::Migration
|
|||
attachments_count = project.attachments.count
|
||||
project.project_score.update_attribute(:attach_num, attachments_count)
|
||||
end
|
||||
# update commits
|
||||
unless project.gpid.nil?
|
||||
g = Gitlab.client
|
||||
begin
|
||||
puts project.id
|
||||
count = g.project(project.gpid).commit_count
|
||||
rescue
|
||||
logger.error("The project's rep is not exit!")
|
||||
end
|
||||
project.project_score.update_attribute(:changeset_num, count)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue