Browse Source

Merge branch 'pre_trustie_server' into trustie_server

pull/345/head
yystopf 2 years ago
parent
commit
a0b7cc99a1
5 changed files with 15 additions and 5 deletions
  1. +4
    -1
      app/controllers/api/v1/projects/commits_controller.rb
  2. +1
    -1
      app/controllers/oauth/acge_controller.rb
  3. +1
    -1
      app/services/api/v1/issues/update_service.rb
  4. +7
    -2
      app/services/api/v1/projects/commits/recent_service.rb
  5. +2
    -0
      app/views/api/v1/projects/commits/recent.json.jbuilder

+ 4
- 1
app/controllers/api/v1/projects/commits_controller.rb View File

@@ -11,6 +11,9 @@ class Api::V1::Projects::CommitsController < Api::V1::BaseController
end

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

+ 1
- 1
app/controllers/oauth/acge_controller.rb View File

@@ -30,7 +30,7 @@ class Oauth::AcgeController < Oauth::BaseController

return
else
username = uid[0..7]
username = uid
password = SecureRandom.hex(4)
reg_result = autologin_register(username, email, password, 'acge', phone, name)
existing_rows = CSV.read("public/操作系统大赛用户信息.csv")


+ 1
- 1
app/services/api/v1/issues/update_service.rb View File

@@ -135,7 +135,7 @@ class Api::V1::Issues::UpdateService < ApplicationService
end

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?
@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


+ 7
- 2
app/services/api/v1/projects/commits/recent_service.rb View File

@@ -1,7 +1,7 @@
class Api::V1::Projects::Commits::RecentService < ApplicationService
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)
@project = project
@@ -15,8 +15,9 @@ class Api::V1::Projects::Commits::RecentService < ApplicationService

def call
load_gitea_data
load_gitea_repo_detail

gitea_data
{result: gitea_data, detail:gitea_repo_detail}
end

private
@@ -36,4 +37,8 @@ class Api::V1::Projects::Commits::RecentService < ApplicationService
raise Error, "获取最近提交列表失败" unless @gitea_data.is_a?(Hash)
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

+ 2
- 0
app/views/api/v1/projects/commits/recent.json.jbuilder View File

@@ -1,4 +1,6 @@
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.sha commit['sha']
json.author do


Loading…
Cancel
Save