This commit is contained in:
huang 2015-12-18 20:46:17 +08:00
parent 747493993b
commit dae6e68623
2 changed files with 28 additions and 19 deletions

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20151218022014) do
ActiveRecord::Schema.define(:version => 20151218110033) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -1361,6 +1361,7 @@ ActiveRecord::Schema.define(:version => 20151218022014) do
t.integer "gpid"
t.integer "forked_from_project_id"
t.integer "forked_count"
t.integer "commits_count", :default => 0
end
add_index "projects", ["lft"], :name => "index_projects_on_lft"

View File

@ -1,18 +1,26 @@
# #coding=utf-8
#
# namespace :projects do
# desc "sync some projects which just have sigle repository"
# task :commits_count => :environment do
# projects = Project.where("gpid is not null")
# puts projects.count
# projects.each do |project|
# unless project.gpid.nil?
# count =
# end
#
# end
# end
#
# task :delete_rep => :environment do
# end
# end
#coding=utf-8
namespace :projects do
desc "sync some projects which just have sigle repository"
task :commits_count => :environment do
projects = Project.where("gpid is not null")
puts projects.count
projects.each do |project|
unless project.gpid.nil?
begin
url = "https://gittest.trustie.net/api/v3/projects/#{project.gpid}/repository/commits_total_count?private_token=kZUYYbAY12QSQ2Tx1zes&ref_name=master"
require 'net/http'
count = Net::HTTP.get(URI(url))
puts "count is ===>#{count}"
ensure
puts "**************** #{project.id}"
end
project.update_attributes(:commits_count => count)
end
end
end
task :delete_rep => :environment do
end
end