| @@ -11,6 +11,9 @@ class Api::V1::Projects::CommitsController < Api::V1::BaseController | |||||
| end | end | ||||
| def recent | def recent | ||||
| @result_object = Api::V1::Projects::Commits::RecentService.call(@project, {keyword: params[:keyword], page: page, limit: limit}, current_user&.gitea_token) | |||||
| hash = Api::V1::Projects::Commits::RecentService.call(@project, {keyword: params[:keyword], page: page, limit: limit}, current_user&.gitea_token) | |||||
| @result_object = hash[:result] | |||||
| @object_detail = hash[:detail] | |||||
| puts @object_detail | |||||
| end | end | ||||
| end | end | ||||
| @@ -30,7 +30,7 @@ class Oauth::AcgeController < Oauth::BaseController | |||||
| return | return | ||||
| else | else | ||||
| username = uid[0..7] | |||||
| username = uid | |||||
| password = SecureRandom.hex(4) | password = SecureRandom.hex(4) | ||||
| reg_result = autologin_register(username, email, password, 'acge', phone, name) | reg_result = autologin_register(username, email, password, 'acge', phone, name) | ||||
| existing_rows = CSV.read("public/操作系统大赛用户信息.csv") | existing_rows = CSV.read("public/操作系统大赛用户信息.csv") | ||||
| @@ -135,7 +135,7 @@ class Api::V1::Issues::UpdateService < ApplicationService | |||||
| end | end | ||||
| def build_previous_issue_changes | def build_previous_issue_changes | ||||
| @previous_issue_changes.merge!(@updated_issue.previous_changes.slice("status_id", "priority_id", "fixed_version_id", "issue_tags_value", "branch_name", "subject", "description").symbolize_keys) | |||||
| @previous_issue_changes.merge!(@updated_issue.previous_changes.slice("status_id", "priority_id", "fixed_version_id", "issue_tags_value", "branch_name", "subject").symbolize_keys) | |||||
| if @updated_issue.previous_changes[:start_date].present? | if @updated_issue.previous_changes[:start_date].present? | ||||
| @previous_issue_changes.merge!(start_date: [@updated_issue.previous_changes[:start_date][0].to_s, @updated_issue.previous_changes[:start_date][1].to_s]) | @previous_issue_changes.merge!(start_date: [@updated_issue.previous_changes[:start_date][0].to_s, @updated_issue.previous_changes[:start_date][1].to_s]) | ||||
| end | end | ||||
| @@ -1,7 +1,7 @@ | |||||
| class Api::V1::Projects::Commits::RecentService < ApplicationService | class Api::V1::Projects::Commits::RecentService < ApplicationService | ||||
| attr_reader :project, :page, :limit, :keyword, :owner, :repo, :token | attr_reader :project, :page, :limit, :keyword, :owner, :repo, :token | ||||
| attr_accessor :gitea_data | |||||
| attr_accessor :gitea_data, :gitea_repo_detail | |||||
| def initialize(project, params, token=nil) | def initialize(project, params, token=nil) | ||||
| @project = project | @project = project | ||||
| @@ -15,8 +15,9 @@ class Api::V1::Projects::Commits::RecentService < ApplicationService | |||||
| def call | def call | ||||
| load_gitea_data | load_gitea_data | ||||
| load_gitea_repo_detail | |||||
| gitea_data | |||||
| {result: gitea_data, detail:gitea_repo_detail} | |||||
| end | end | ||||
| private | private | ||||
| @@ -36,4 +37,8 @@ class Api::V1::Projects::Commits::RecentService < ApplicationService | |||||
| raise Error, "获取最近提交列表失败" unless @gitea_data.is_a?(Hash) | raise Error, "获取最近提交列表失败" unless @gitea_data.is_a?(Hash) | ||||
| end | end | ||||
| def load_gitea_repo_detail | |||||
| @gitea_repo_detail = $gitea_client.get_repos_by_owner_repo(owner, repo, {query: {access_token: token}}) | |||||
| raise Error, "获取项目详情失败" unless @gitea_repo_detail.is_a?(Hash) | |||||
| end | |||||
| end | end | ||||
| @@ -1,4 +1,6 @@ | |||||
| json.total_count @result_object[:total_data].to_i | json.total_count @result_object[:total_data].to_i | ||||
| json.ssh_url @object_detail['ssh_url'] | |||||
| json.clone_url @object_detail['clone_url'] | |||||
| json.commits @result_object[:data].each do |commit| | json.commits @result_object[:data].each do |commit| | ||||
| json.sha commit['sha'] | json.sha commit['sha'] | ||||
| json.author do | json.author do | ||||