You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trustieforge/lib/tasks/update_project_commits.rake

26 lines
759 B

#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