Merge branch 'develop' into szzh

This commit is contained in:
huang 2015-12-18 21:36:09 +08:00
commit 2efb7b6e66
1 changed files with 26 additions and 26 deletions

View File

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