diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index e6fef78f0..71c174f42 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -262,7 +262,7 @@ class RepositoriesController < ApplicationController archive_url = "/repos/#{@owner.login}/#{@repository.identifier}/archive/#{Addressable::URI.escape(params[:archive])}" file_path = [domain, api_url, archive_url].join - file_path = [file_path, "access_token=#{current_user&.gitea_token}"].join("?") if @repository.hidden? + file_path = [file_path, "access_token=#{current_user&.gitea_token}"].join("?") return render_not_found if !request.format.zip? && !request.format.gzip? diff --git a/app/controllers/users/statistics_controller.rb b/app/controllers/users/statistics_controller.rb index 1948af9b3..013191910 100644 --- a/app/controllers/users/statistics_controller.rb +++ b/app/controllers/users/statistics_controller.rb @@ -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 diff --git a/app/services/gitea/user/headmap_service.rb b/app/services/gitea/user/headmap_service.rb index d066d0f16..eef8e21a9 100644 --- a/app/services/gitea/user/headmap_service.rb +++ b/app/services/gitea/user/headmap_service.rb @@ -1,10 +1,11 @@ class Gitea::User::HeadmapService < Gitea::ClientService - attr_reader :start_time, :end_time, :username + attr_reader :start_time, :end_time, :username, :token - def initialize(username, start_time, end_time) + def initialize(username, start_time, end_time, token=nil) @username = username @start_time = start_time @end_time = end_time + @token = token end def call @@ -14,7 +15,7 @@ class Gitea::User::HeadmapService < Gitea::ClientService private def params - Hash.new.merge(start: start_time, end: end_time) + Hash.new.merge(start: start_time, end: end_time, token: token) end def url diff --git a/app/views/api/v1/projects/branches/all.json.jbuilder b/app/views/api/v1/projects/branches/all.json.jbuilder index d89b1ee16..4a9f2a12b 100644 --- a/app/views/api/v1/projects/branches/all.json.jbuilder +++ b/app/views/api/v1/projects/branches/all.json.jbuilder @@ -1,3 +1,3 @@ -json.array! @result_object["branch_name"] do |branch| +json.array! @result_object do |branch| json.partial! "api/v1/projects/branches/simple_detail", branch: branch end \ No newline at end of file