diff --git a/app/tasks/sync_user_forge_task.rb b/app/tasks/sync_user_forge_task.rb index 58fd203ef..1cb58dd45 100644 --- a/app/tasks/sync_user_forge_task.rb +++ b/app/tasks/sync_user_forge_task.rb @@ -6,18 +6,22 @@ class SyncUserForgeTask def call Rails.logger.info("##########_______sync_start________###########") - all_users = User.where("login is not null and id = ?",25728) + all_users = User.where("login is not null") # 这里再把所有用户循环 all_users.find_each do |u| - # u = User.find(36390) 测试的 user_params = u.as_json user_extension_params = u.try(:user_extensions).as_json || [] target_params = [] if u.projects.present? - projects = u.projects.includes(:versions,:project_score, issues: [:journals],owner: [:user_extensions], members: [roles: [:member_roles]]) + projects = u.projects.includes(:versions,:repository,:project_score, issues: [:journals],owner: [:user_extensions], members: [roles: [:member_roles]]) projects.find_each do |p| + identifier = p.try(:identifier) + if p.repository.present? && p.repository.try(:identifier).present? + identifier = p.repository.try(:identifier) + end member_params = get_members(p.members,p) project_params = p.as_json + project_params["project"]["identifier"] = identifier issue_params = get_issues(p, u.id) versions_params = get_versions(p) project_score_params = get_scores(p)