修改sync_user_forge_task.rb
This commit is contained in:
parent
912dca0deb
commit
aa4fec052c
|
@ -7,6 +7,7 @@ class SyncUserForgeTask
|
|||
def call
|
||||
Rails.logger.info("##########_______sync_start________###########")
|
||||
all_users = User.where("login is not null")
|
||||
# .where(id: [3136,11891,3051])
|
||||
# 这里再把所有用户循环
|
||||
all_users.find_each do |u|
|
||||
user_params = u.as_json
|
||||
|
@ -20,9 +21,15 @@ class SyncUserForgeTask
|
|||
identifier = p.repository.try(:identifier)
|
||||
end
|
||||
member_params = get_members(p.members,p)
|
||||
watchers_params = get_watchers(p.watchers)
|
||||
praise_trends_params = get_praises(p.id)
|
||||
issue_params = get_issues(p, u.id)
|
||||
project_params = p.as_json
|
||||
project_params["project"]["identifier"] = identifier
|
||||
issue_params = get_issues(p, u.id)
|
||||
project_params["project"]["watchers_count"] = watchers_params.size
|
||||
project_params["project"]["issues_count"] = issue_params.size
|
||||
project_params["project"]["praises_count"] = praise_trends_params.size
|
||||
|
||||
versions_params = get_versions(p)
|
||||
project_score_params = get_scores(p)
|
||||
pull_request_params = get_prs(p.id)
|
||||
|
@ -36,7 +43,9 @@ class SyncUserForgeTask
|
|||
project_score_params: project_score_params,
|
||||
pull_request_params: pull_request_params,
|
||||
repo_params: repo_params,
|
||||
commit_params: commit_params
|
||||
commit_params: commit_params,
|
||||
watchers_params: watchers_params,
|
||||
praise_trends_params: praise_trends_params
|
||||
}
|
||||
target_params.push(relate_project_params)
|
||||
end
|
||||
|
@ -112,10 +121,11 @@ class SyncUserForgeTask
|
|||
|
||||
#repository的内容
|
||||
def get_repository(project)
|
||||
repo_params = []
|
||||
repo = project.repository
|
||||
repo_params.push(repo.as_json) if repo.present?
|
||||
repo_params
|
||||
project.try(:repository).as_json || []
|
||||
# repo_params = []
|
||||
# repo = project.repository
|
||||
# repo_params.push(repo.as_json) if repo.present?
|
||||
# repo_params
|
||||
end
|
||||
|
||||
def get_issue_journal(issue, user_id)
|
||||
|
@ -161,4 +171,25 @@ class SyncUserForgeTask
|
|||
end
|
||||
member_params
|
||||
end
|
||||
|
||||
def get_watchers(watchers)
|
||||
watcher_params = []
|
||||
if watchers.present?
|
||||
watchers.find_each do |m|
|
||||
watcher_params.push(m.as_json)
|
||||
end
|
||||
end
|
||||
watcher_params
|
||||
end
|
||||
|
||||
def get_praises(project_id)
|
||||
prasie_params = []
|
||||
praise_trends = PraiseTread.where(praise_tread_object_id: project_id, praise_tread_object_type: "Project")
|
||||
if praise_trends.present?
|
||||
praise_trends.find_each do |m|
|
||||
prasie_params.push(m.as_json)
|
||||
end
|
||||
end
|
||||
prasie_params
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue