parent
5fe4e9e813
commit
a68392fd24
|
@ -173,14 +173,18 @@ class Issue < ActiveRecord::Base
|
||||||
|
|
||||||
# 创建issue的时候,issues_count加1
|
# 创建issue的时候,issues_count加1
|
||||||
def add_issues_count
|
def add_issues_count
|
||||||
issue_count = self.project.issues_count + 1
|
unless self.project.project_score.nil?
|
||||||
self.project.update_attribute(:issues_count, issue_count)
|
issue_count = self.project.project_score.issue_num + 1
|
||||||
|
self.project.project_score.update_attribute(:issue_num, issue_count)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# 删除issue的时候,issues_count减1
|
# 删除issue的时候,issues_count减1
|
||||||
def decrease_issues_count
|
def decrease_issues_count
|
||||||
issue_count = self.project.issues_count - 1
|
unless self.project.project_score.nil?
|
||||||
self.project.update_attribute(:issues_count, issue_count)
|
issue_count = self.project.project_score.issue_num - 1
|
||||||
|
self.project.project_score.update_attribute(:issue_num, issue_count)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# 更新缺陷
|
# 更新缺陷
|
||||||
|
|
|
@ -5,6 +5,10 @@ class UpdateProjectScore < ActiveRecord::Migration
|
||||||
for i in 1 ... project_count do i
|
for i in 1 ... project_count do i
|
||||||
Project.page(i).per(30).each do |project|
|
Project.page(i).per(30).each do |project|
|
||||||
puts project.id
|
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?
|
unless project.project_score.nil?
|
||||||
# update boards
|
# update boards
|
||||||
unless project.boards.first.nil?
|
unless project.boards.first.nil?
|
||||||
|
@ -40,6 +44,17 @@ class UpdateProjectScore < ActiveRecord::Migration
|
||||||
attachments_count = project.attachments.count
|
attachments_count = project.attachments.count
|
||||||
project.project_score.update_attribute(:attach_num, attachments_count)
|
project.project_score.update_attribute(:attach_num, attachments_count)
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue