renwu
This commit is contained in:
parent
747493993b
commit
dae6e68623
|
@ -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"
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue