版本库提交次数迁移

This commit is contained in:
huang 2016-01-15 21:19:52 +08:00
parent b2746d0953
commit ed26242f94
2 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,32 @@
class UpdateRepCommits < ActiveRecord::Migration
def up
project_count = Project.all.count / 30 + 2
transaction do
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.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
def down
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160115023749) do ActiveRecord::Schema.define(:version => 20160115125217) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false