Browse Source

Change

pull/278/head
sylor_huang@126.com 5 years ago
parent
commit
98da7ea34d
1 changed files with 12 additions and 3 deletions
  1. +12
    -3
      app/tasks/sync_forge_projects_rake.rb

+ 12
- 3
app/tasks/sync_forge_projects_rake.rb View File

@@ -2,10 +2,19 @@ require 'uri'
require 'net/http'

class SyncForgeProjectsRake
# 运行示例: 检查哪些项目的repo不存在,bundle exec rails runner "SyncForgeProjectsRake.new.call()"
# 运行示例: 检查哪些项目的repo不存在,bundle exec rails runner "SyncForgeProjectsRake.new.call(5)"
def call
def call(count)
url = "https://forgeplus.trustie.net/api/sync_forge/sync_range_projects" #trustie上的相关路由
count_params = {
sync_count: count || 10
}
uri = URI.parse(url)
http = Net::HTTP.new(uri.hostname, uri.port)
http.use_ssl = true
response = http.send_request('POST', uri.path, count_params.to_json, {'Content-Type' => 'application/json'})
Rails.logger.info("============end to sync project, status: #{response.code} ===========")


end
end

Loading…
Cancel
Save