|
|
|
@@ -4,7 +4,7 @@ class Users::StatisticsController < Users::BaseController |
|
|
|
# 近期活动统计 |
|
|
|
def activity |
|
|
|
date_range = (1.week.ago.to_date..Date.today).to_a |
|
|
|
commit_request = Gitea::User::HeadmapService.call(observed_user.login, 1.week.ago.to_date.to_time.to_i, Date.today.to_time.to_i) |
|
|
|
commit_request = Gitea::User::HeadmapService.call(observed_user.login, 1.week.ago.to_date.to_time.to_i, Date.today.end_of_day.to_time.to_i, observed_user.gitea_token) |
|
|
|
commit_data = commit_request[2] |
|
|
|
@date_data = [] |
|
|
|
@issue_data = [] |
|
|
|
@@ -14,8 +14,11 @@ class Users::StatisticsController < Users::BaseController |
|
|
|
@date_data << date.strftime("%Y.%m.%d") |
|
|
|
@issue_data << observed_user.issues.issue_issue.where("DATE(created_on) = ?", date).size |
|
|
|
@pull_request_data << observed_user.pull_requests.where("DATE(created_at) = ?", date).size |
|
|
|
date_commit_data = commit_data.blank? ? nil : commit_data.select{|item| item["timestamp"] == date.to_time.to_i} |
|
|
|
@commit_data << (date_commit_data.blank? ? 0 : date_commit_data[0]["contributions"].to_i) |
|
|
|
contribution = 0 |
|
|
|
commit_data.each do |item| |
|
|
|
contribution += item["contributions"] if Time.at(item["timestamp"]).strftime("%Y-%m-%d") == date.to_s |
|
|
|
end |
|
|
|
@commit_data << contribution |
|
|
|
end |
|
|
|
render :json => {dates: @date_data, issues_count: @issue_data, pull_requests_count: @pull_request_data, commits_count: @commit_data} |
|
|
|
end |
|
|
|
|