forked from Gitlink/forgeplus
Merge branch 'dev_trustie' of http://gitea.trustie.net/jasder/forgeplus into dev_trustie
This commit is contained in:
commit
1d827580ff
|
@ -80,3 +80,4 @@ docker/
|
|||
educoder.sql
|
||||
redis_data/
|
||||
Dockerfile
|
||||
dump.rdb
|
1
Gemfile
1
Gemfile
|
@ -66,6 +66,7 @@ group :development, :test do
|
|||
end
|
||||
|
||||
group :development do
|
||||
gem 'prettier'
|
||||
gem 'rubocop', '~> 0.52.0'
|
||||
gem 'solargraph', '~> 0.38.0'
|
||||
gem 'awesome_print'
|
||||
|
|
|
@ -218,6 +218,7 @@ GEM
|
|||
activerecord (>= 5.2.1)
|
||||
popper_js (1.16.0)
|
||||
powerpack (0.1.2)
|
||||
prettier (0.18.2)
|
||||
public_suffix (4.0.3)
|
||||
puma (3.12.2)
|
||||
rack (2.0.9)
|
||||
|
@ -466,6 +467,7 @@ DEPENDENCIES
|
|||
omniauth-oauth2 (~> 1.6.0)
|
||||
parallel (~> 1.19, >= 1.19.1)
|
||||
pdfkit
|
||||
prettier
|
||||
puma (~> 3.11)
|
||||
rack-cors
|
||||
rack-mini-profiler
|
||||
|
|
|
@ -13,14 +13,15 @@ class IssuesController < ApplicationController
|
|||
|
||||
def index
|
||||
@user_admin_or_member = current_user.present? && current_user.logged? && (current_user.admin || @project.member?(current_user))
|
||||
issues = @project.issues.issue_issue
|
||||
issues = @project.issues.issue_issue.issue_index_includes
|
||||
issues = issues.where(is_private: false) unless @user_admin_or_member
|
||||
|
||||
@all_issues_size = issues.size
|
||||
@open_issues_size = issues.where.not(status_id: 5).size
|
||||
@close_issues_size = issues.where(status_id: 5).size
|
||||
@assign_to_me_size = issues.where(assigned_to_id: current_user&.id).size
|
||||
@my_published_size = issues.where(author_id: current_user&.id).size
|
||||
scopes = Issues::ListQueryService.call(issues,params.delete_if{|k,v| v.blank?})
|
||||
scopes = Issues::ListQueryService.call(issues,params.delete_if{|k,v| v.blank?}, "Issue")
|
||||
@issues_size = scopes.size
|
||||
@issues = paginate(scopes)
|
||||
|
||||
|
@ -105,13 +106,8 @@ class IssuesController < ApplicationController
|
|||
elsif params[:subject].to_s.size > 255
|
||||
normal_status(-1, "标题不能超过255个字符")
|
||||
elsif (params[:issue_type].to_s == "2")
|
||||
return normal_status(-1, "悬赏的奖金必须大于0")if params[:token].to_i == 0
|
||||
#查看当前用户的积分
|
||||
query_params = {
|
||||
type: "user"
|
||||
}.merge(tokens_params(@project))
|
||||
user_tokens = Gitea::Repository::Hooks::QueryService.new(query_params).call
|
||||
return normal_status(-1, "您的token值不足") if user_tokens[:value].to_i < params[:token].to_i
|
||||
return normal_status(-1, "悬赏的奖金必须大于0") if params[:token].to_i == 0
|
||||
|
||||
else
|
||||
issue_params = issue_send_params(params)
|
||||
|
||||
|
@ -140,15 +136,6 @@ class IssuesController < ApplicationController
|
|||
tiding_type: 'issue', status: 0)
|
||||
end
|
||||
|
||||
#为悬赏任务时, 扣除当前用户的积分
|
||||
if params[:issue_type].to_s == "2"
|
||||
change_params = {
|
||||
change_type: "minusToken",
|
||||
tokens: params[:token]
|
||||
}.merge(tokens_params(@project))
|
||||
ChangeTokenJob.perform_later(change_params)
|
||||
end
|
||||
|
||||
@issue.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "create")
|
||||
normal_status(0, "创建成功")
|
||||
else
|
||||
|
@ -211,21 +198,6 @@ class IssuesController < ApplicationController
|
|||
@issue.update_closed_issues_count_in_project!
|
||||
end
|
||||
|
||||
if @issue.issue_type.to_s == "2"
|
||||
#表示修改token值
|
||||
if @issue.saved_change_to_attribute("token")
|
||||
last_token = @issue.token_was
|
||||
change_token = last_token - @issue.token
|
||||
change_type = change_token > 0 ? "addToken" : "minusToken"
|
||||
change_params = {
|
||||
change_type: change_type,
|
||||
tokens: change_token.abs
|
||||
}.merge(tokens_params(@proeject))
|
||||
ChangeTokenJob.perform_later(change_params)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@issue.create_journal_detail(change_files, issue_files, issue_file_ids, current_user&.id)
|
||||
normal_status(0, "更新成功")
|
||||
else
|
||||
|
@ -241,13 +213,13 @@ class IssuesController < ApplicationController
|
|||
@issue_assign_to = @issue.get_assign_user
|
||||
@join_users = join_users(@issue)
|
||||
#总耗时
|
||||
cost_time(@issue)
|
||||
# cost_time(@issue)
|
||||
|
||||
#被依赖
|
||||
@be_depended_issues_array = be_depended_issues(@issue)
|
||||
# #被依赖
|
||||
# @be_depended_issues_array = be_depended_issues(@issue)
|
||||
|
||||
#依赖于
|
||||
depended_issues(@issue)
|
||||
# #依赖于
|
||||
# depended_issues(@issue)
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
@ -272,7 +244,6 @@ class IssuesController < ApplicationController
|
|||
end
|
||||
|
||||
def series_update
|
||||
|
||||
update_hash = {}
|
||||
update_hash.merge!(assigned_to_id: params[:assigned_to_id]) if params[:assigned_to_id].present?
|
||||
update_hash.merge!(fixed_version_id: params[:fixed_version_id]) if params[:fixed_version_id].present?
|
||||
|
@ -310,8 +281,6 @@ class IssuesController < ApplicationController
|
|||
|
||||
def close_issue
|
||||
type = params[:status_id].to_i || 5
|
||||
return normal_status(-1, "悬赏工单不允许再次打开") if @issue.issue_type.to_s == "2" && @issue.status_id.to_i == 5
|
||||
return normal_status(-1, "您没有权限操作") if @issue.issue_type.to_s == "2" && (@issue.user_id != current_user&.id || !current_user&.admin?)
|
||||
|
||||
if type == 5
|
||||
message = "关闭"
|
||||
|
@ -323,19 +292,7 @@ class IssuesController < ApplicationController
|
|||
if @issue.update_attribute(:status_id, type)
|
||||
if type == 5
|
||||
@issue&.project_trends&.update_all(action_type: "close")
|
||||
|
||||
@issue.issue_times.update_all(end_time: Time.now)
|
||||
if @issue.issue_type.to_s == "2"
|
||||
tokens = @issue.token
|
||||
change_params = {
|
||||
change_type: "addToken",
|
||||
tokens: tokens,
|
||||
ownername: project.owner.try(:login),
|
||||
reponame: project.try(:identifer),
|
||||
username: @issue.get_assign_user.try(:login) #指派人增加积分
|
||||
}
|
||||
ChangeTokenJob.perform_later(change_params)
|
||||
end
|
||||
if @issue.issue_classify.to_s == "pull_request"
|
||||
@issue&.pull_request&.update_attribute(:status, 2)
|
||||
end
|
||||
|
@ -467,13 +424,4 @@ class IssuesController < ApplicationController
|
|||
project_id: @project.id
|
||||
}
|
||||
end
|
||||
|
||||
def tokens_params(project)
|
||||
{
|
||||
ownername: project.owner.try(:login),
|
||||
reponame: project.try(:identifer),
|
||||
username: current_user.try(:login)
|
||||
}
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -81,19 +81,19 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def watch_users
|
||||
watchers = @project.watchers.includes(:user).order("watchers.created_at asc").distinct
|
||||
watchers = @project.watchers.includes(:user).order("watchers.created_at desc").distinct
|
||||
@watchers_count = watchers.size
|
||||
@watchers = paginate(watchers)
|
||||
end
|
||||
|
||||
def praise_users
|
||||
praises = @project.praise_treads.includes(:user).order("praise_treads.created_at asc").distinct
|
||||
praises = @project.praise_treads.includes(:user).order("praise_treads.created_at desc").distinct
|
||||
@praises_count = praises.size
|
||||
@praises = paginate(praises)
|
||||
end
|
||||
|
||||
def fork_users
|
||||
fork_users = @project.fork_users.includes(:user, :project).order("fork_users.created_at asc").distinct
|
||||
fork_users = @project.fork_users.includes(:user, :project).order("fork_users.created_at desc").distinct
|
||||
@forks_count = fork_users.size
|
||||
@fork_users = paginate(fork_users)
|
||||
end
|
||||
|
|
|
@ -3,22 +3,22 @@ class PullRequestsController < ApplicationController
|
|||
before_action :find_project_with_id
|
||||
before_action :set_repository
|
||||
before_action :find_pull_request, except: [:index, :new, :create, :check_can_merge]
|
||||
before_action :get_relatived, only: [:new, :edit]
|
||||
include TagChosenHelper
|
||||
include ApplicationHelper
|
||||
|
||||
|
||||
def index
|
||||
# @issues = Gitea::PullRequest::ListService.new(@user,@repository.try(:identifier)).call #通过gitea获取
|
||||
issues = @project.issues.issue_pull_request
|
||||
issues = @project.issues.issue_pull_request.issue_index_includes.includes(:pull_request)
|
||||
issues = issues.where(is_private: false) unless current_user.present? && (current_user.admin? || @project.member?(current_user))
|
||||
@all_issues_size = issues.size
|
||||
@open_issues_size = issues.where.not(status_id: 5).size
|
||||
@close_issues_size = issues.where(status_id: 5).size
|
||||
@assign_to_me_size = issues.where(assigned_to_id: current_user&.id).size
|
||||
@my_published_size = issues.where(author_id: current_user&.id).size
|
||||
@open_issues_size = issues.joins(:pull_request).where(pull_requests: {status: 0}).size
|
||||
@close_issues_size = issues.joins(:pull_request).where(pull_requests: {status: 2}).size
|
||||
@merged_issues_size = issues.joins(:pull_request).where(pull_requests: {status: 1}).size
|
||||
@user_admin_or_member = current_user.present? && (current_user.admin || @project.member?(current_user))
|
||||
|
||||
scopes = Issues::ListQueryService.call(issues,params.delete_if{|k,v| v.blank?})
|
||||
scopes = Issues::ListQueryService.call(issues,params.delete_if{|k,v| v.blank?}, "PullRequest")
|
||||
@issues_size = scopes.size
|
||||
@issues = paginate(scopes)
|
||||
end
|
||||
|
@ -31,13 +31,9 @@ class PullRequestsController < ApplicationController
|
|||
@all_branches.push(b["name"])
|
||||
end
|
||||
end
|
||||
@project_tags = @project.issue_tags&.select(:id,:name, :color).as_json
|
||||
@project_versions = @project.versions&.select(:id,:name, :status).as_json
|
||||
@project_members = @project.members_user_infos
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
if params[:title].nil?
|
||||
normal_status(-1, "名称不能为空")
|
||||
elsif params[:issue_tag_ids].nil?
|
||||
|
@ -45,55 +41,18 @@ class PullRequestsController < ApplicationController
|
|||
else
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
local_params = {
|
||||
title: params[:title], #标题
|
||||
body: params[:body], #内容
|
||||
head: params[:head], #源分支
|
||||
base: params[:base], #目标分支
|
||||
milestone: 0, #里程碑,未与本地的里程碑关联
|
||||
}
|
||||
requests_params = local_params.merge({
|
||||
assignee: current_user.try(:login),
|
||||
assignees: ["#{params[:assigned_login].to_s}"],
|
||||
labels: params[:issue_tag_ids],
|
||||
due_date: Time.now
|
||||
})
|
||||
issue_params = {
|
||||
author_id: current_user.id,
|
||||
project_id: @project.id,
|
||||
subject: params[:title],
|
||||
description: params[:body],
|
||||
assigned_to_id: params[:assigned_to_id],
|
||||
fixed_version_id: params[:fixed_version_id],
|
||||
issue_tags_value: params[:issue_tag_ids].present? ? params[:issue_tag_ids].join(",") : "",
|
||||
issue_classify: "pull_request",
|
||||
issue_type: params[:issue_type] || "1",
|
||||
tracker_id: 2,
|
||||
status_id: 1,
|
||||
priority_id: 1
|
||||
}
|
||||
pull_issue = Issue.new(issue_params)
|
||||
merge_params
|
||||
pull_issue = Issue.new(@issue_params)
|
||||
if pull_issue.save!
|
||||
local_requests = PullRequest.new(local_params.merge(user_id: current_user.try(:id), project_id: @project.id, issue_id: pull_issue.id))
|
||||
local_requests = PullRequest.new(@local_params.merge(user_id: current_user.try(:id), project_id: @project.id, issue_id: pull_issue.id))
|
||||
if local_requests.save
|
||||
gitea_request = Gitea::PullRequest::CreateService.new(current_user.try(:gitea_token), @project.owner, @repository.try(:identifier), requests_params).call
|
||||
gitea_request = Gitea::PullRequest::CreateService.new(current_user.try(:gitea_token), @project.owner, @repository.try(:identifier), @requests_params).call
|
||||
if gitea_request && local_requests.update_attributes(gpid: gitea_request["number"])
|
||||
if params[:issue_tag_ids].present?
|
||||
params[:issue_tag_ids].each do |tag|
|
||||
IssueTagsRelate.create!(issue_id: pull_issue.id, issue_tag_id: tag)
|
||||
end
|
||||
end
|
||||
if params[:attachment_ids].present?
|
||||
params[:attachment_ids].each do |id|
|
||||
attachment = Attachment.select(:id, :container_id, :container_type)&.find_by_id(id)
|
||||
unless attachment.blank?
|
||||
attachment.container = pull_issue
|
||||
attachment.author_id = current_user.id
|
||||
attachment.description = ""
|
||||
attachment.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if params[:assigned_to_id].present?
|
||||
Tiding.create!(user_id: params[:assigned_to_id], trigger_user_id: current_user.id,
|
||||
|
@ -122,8 +81,7 @@ class PullRequestsController < ApplicationController
|
|||
end
|
||||
|
||||
def edit
|
||||
@issue_chosen = issue_left_chosen(@project, @issue.id)
|
||||
@issue_attachments = @issue.attachments
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
|
@ -134,25 +92,7 @@ class PullRequestsController < ApplicationController
|
|||
else
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
local_params = {
|
||||
title: params[:title], #标题
|
||||
body: params[:body], #内容
|
||||
head: params[:head], #源分支
|
||||
base: params[:base], #目标分支
|
||||
milestone: 0, #里程碑,未与本地的里程碑关联
|
||||
}
|
||||
requests_params = local_params.merge({
|
||||
assignee: current_user.try(:login),
|
||||
assignees: ["#{params[:assigned_login].to_s}"],
|
||||
labels: params[:issue_tag_ids]
|
||||
})
|
||||
issue_params = {
|
||||
subject: params[:title],
|
||||
description: params[:body],
|
||||
assigned_to_id: params[:assigned_to_id].to_s,
|
||||
fixed_version_id: params[:fixed_version_id],
|
||||
issue_tags_value: params[:issue_tag_ids].present? ? params[:issue_tag_ids].join(",") : "",
|
||||
}
|
||||
merge_params
|
||||
|
||||
if params[:issue_tag_ids].present? && !@issue&.issue_tags_relates.where(issue_tag_id: params[:issue_tag_ids]).exists?
|
||||
@issue&.issue_tags_relates&.destroy_all
|
||||
|
@ -161,26 +101,10 @@ class PullRequestsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
if @issue.update_attributes(issue_params)
|
||||
if @pull_request.update_attributes(local_params)
|
||||
gitea_request = Gitea::PullRequest::UpdateService.new(current_user, @repository.try(:identifier), requests_params, @pull_request.try(:gpid)).call
|
||||
if @issue.update_attributes(@issue_params)
|
||||
if @pull_request.update_attributes(@local_params)
|
||||
gitea_request = Gitea::PullRequest::UpdateService.new(current_user, @repository.try(:identifier), @requests_params, @pull_request.try(:gpid)).call
|
||||
if gitea_request
|
||||
issue_files = params[:attachment_ids]
|
||||
change_files = false
|
||||
issue_file_ids = []
|
||||
|
||||
if issue_files.present?
|
||||
change_files = true
|
||||
issue_files.each do |id|
|
||||
attachment = Attachment.select(:id, :container_id, :container_type)&.find_by_id(id)
|
||||
unless attachment.blank?
|
||||
attachment.container = @issue
|
||||
attachment.author_id = current_user.id
|
||||
attachment.description = ""
|
||||
attachment.save
|
||||
end
|
||||
end
|
||||
end
|
||||
if params[:issue_tag_ids].present?
|
||||
params[:issue_tag_ids].each do |tag|
|
||||
IssueTagsRelate.create(issue_id: @issue.id, issue_tag_id: tag)
|
||||
|
@ -189,7 +113,6 @@ class PullRequestsController < ApplicationController
|
|||
if params[:status_id].to_i == 5
|
||||
@issue.issue_times.update_all(end_time: Time.now)
|
||||
end
|
||||
@issue.create_journal_detail(change_files, issue_files, issue_file_ids, current_user&.id)
|
||||
normal_status(0, "PullRequest更新成功")
|
||||
else
|
||||
normal_status(-1, "PullRequest更新失败")
|
||||
|
@ -207,52 +130,24 @@ class PullRequestsController < ApplicationController
|
|||
|
||||
end
|
||||
|
||||
def simple_update
|
||||
def refuse_merge
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
issue_params = {
|
||||
assigned_to_id: params[:assigned_to_id].to_s,
|
||||
fixed_version_id: params[:fixed_version_id],
|
||||
issue_tags_value: params[:issue_tag_ids].present? ? params[:issue_tag_ids].join(",") : "",
|
||||
}
|
||||
if params[:issue_tag_ids].blank?
|
||||
@issue&.issue_tags_relates&.destroy_all
|
||||
end
|
||||
|
||||
if params[:issue_tag_ids].present? && !@issue&.issue_tags_relates.where(issue_tag_id: params[:issue_tag_ids]).exists?
|
||||
@issue&.issue_tags_relates&.destroy_all
|
||||
params[:issue_tag_ids].each do |tag|
|
||||
IssueTagsRelate.create(issue_id: @issue.id, issue_tag_id: tag)
|
||||
end
|
||||
end
|
||||
|
||||
if @issue.update_attributes(issue_params)
|
||||
normal_status(0, "PullRequest更新成功")
|
||||
else
|
||||
normal_status(-1, "PullRequest更新成功")
|
||||
end
|
||||
@pull_request.update(status: 2)
|
||||
@pull_request.issue.update(status_id: 5)
|
||||
normal_status(1, "已拒绝")
|
||||
rescue => e
|
||||
normal_status(-1, e.message)
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
@user_permission = current_user.present? && current_user.logged? && (!@issue.is_lock || @project.member?(current_user) || current_user.admin? || @issue.user == current_user)
|
||||
@issue_attachments = @issue.attachments
|
||||
@user_permission = current_user.present? && current_user.logged? && (@issue.assigned_to_id == current_user.id || current_user.admin? )
|
||||
@issue_user = @issue.user
|
||||
@issue_assign_to = @issue.get_assign_user
|
||||
@join_users = join_users(@issue)
|
||||
#总耗时
|
||||
cost_time(@issue)
|
||||
|
||||
#被依赖
|
||||
@be_depended_issues_array = be_depended_issues(@issue)
|
||||
|
||||
#依赖于
|
||||
depended_issues(@issue)
|
||||
end
|
||||
|
||||
def pr_merge
|
||||
|
@ -268,9 +163,7 @@ class PullRequestsController < ApplicationController
|
|||
}
|
||||
merge_pr = Gitea::PullRequest::MergeService.new(current_user, @repository.try(:identifier), @pull_request.try(:gpid), requests_params).call
|
||||
if @pull_request.update_attribute(:status, 1) && merge_pr[:status].to_i == 200
|
||||
# @pull_request.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "merge")
|
||||
@pull_request&.project_trends&.update_all(action_type: "close")
|
||||
|
||||
@issue&.custom_journal_detail("merge", "", "该合并请求已被合并", current_user&.id)
|
||||
normal_status(1, "合并成功")
|
||||
else
|
||||
|
@ -284,73 +177,20 @@ class PullRequestsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#评审
|
||||
def check_merge
|
||||
notes = params[:content]
|
||||
pull_request_status = params[:status]
|
||||
if notes.blank?
|
||||
normal_status(-1, "评论内容不能为空")
|
||||
else
|
||||
if @pull_request.status > 0
|
||||
normal_status(-1, "已合并,不能评审")
|
||||
else
|
||||
if pull_request_status.to_i == 1
|
||||
message = "评审通过:"
|
||||
elsif pull_request_status.to_i == 2
|
||||
message = "评审请求变更:"
|
||||
else
|
||||
message = ""
|
||||
end
|
||||
journal_params = {
|
||||
journalized_id: @issue.id ,
|
||||
journalized_type: "Issue",
|
||||
user_id: current_user.id ,
|
||||
notes: message + notes.to_s.strip
|
||||
}
|
||||
journal = Journal.new journal_params
|
||||
if journal.save
|
||||
if pull_request_status.present?
|
||||
@pull_request.update_attribute(:status, pull_request_status.to_i)
|
||||
end
|
||||
if pull_request_status.to_i == 1
|
||||
requests_params = {
|
||||
do: "merge",
|
||||
MergeMessageField: notes,
|
||||
MergeTitleField: "Merge PullRequest ##{@pull_request.gpid}"
|
||||
}
|
||||
merge_pr = Gitea::PullRequest::MergeService.new(current_user, @repository.try(:identifier), @pull_request.try(:gpid), requests_params).call
|
||||
if merge_pr
|
||||
@pull_request&.project_trends&.update_all(action_type: "close")
|
||||
# @pull_request.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "merge")
|
||||
@issue.custom_journal_detail("merge", "", "该合并请求已被合并", current_user&.id)
|
||||
normal_status(1, "评审成功")
|
||||
else
|
||||
normal_status(-1, "评审失败")
|
||||
end
|
||||
end
|
||||
normal_status(0, "评审成功")
|
||||
else
|
||||
normal_status(-1, "评审失败")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def check_can_merge
|
||||
target_head = params[:head] #源分支
|
||||
target_base = params[:base] #目标分支
|
||||
if target_head.blank? || target_base.blank?
|
||||
normal_status(-1, "请选择分支。")
|
||||
normal_status(-2, "请选择分支")
|
||||
elsif target_head === target_base
|
||||
normal_status(-1, "分支内容相同,无需创建合并请求。")
|
||||
normal_status(-2, "分支内容相同,无需创建合并请求")
|
||||
else
|
||||
can_merge = @project&.pull_requests.where(user_id: current_user&.id, head: target_head, base: target_base, status: 0)
|
||||
if can_merge.present?
|
||||
render json: {
|
||||
status: -2,
|
||||
message: "在这些分支之间的合并请求已存在",
|
||||
pull_request_id: can_merge.first.id,
|
||||
pull_request_name: can_merge.first.try(:title)
|
||||
message: "在这些分支之间的合并请求已存在:<a href='/projects/#{@project.id}/merge/#{can_merge.first.id}/Messagecount''>#{can_merge.first.try(:title)}</a>",
|
||||
}
|
||||
else
|
||||
normal_status(0, "可以合并")
|
||||
|
@ -362,10 +202,8 @@ class PullRequestsController < ApplicationController
|
|||
private
|
||||
|
||||
def set_repository
|
||||
# @project = Project.find_by_identifier! params[:id]
|
||||
@repository = @project.repository
|
||||
@user = @project.owner
|
||||
# normal_status(-1, "项目不存在") unless @project.present?
|
||||
normal_status(-1, "仓库不存在") unless @repository.present?
|
||||
normal_status(-1, "用户不存在") unless @user.present?
|
||||
end
|
||||
|
@ -379,4 +217,41 @@ class PullRequestsController < ApplicationController
|
|||
normal_status(-1, "您没有权限")
|
||||
end
|
||||
end
|
||||
|
||||
def get_relatived
|
||||
@project_tags = @project.issue_tags&.select(:id,:name, :color).as_json
|
||||
@project_versions = @project.versions&.select(:id,:name, :status).as_json
|
||||
@project_members = @project.members_user_infos
|
||||
@project_priories = IssuePriority&.select(:id,:name, :position).as_json
|
||||
end
|
||||
|
||||
def merge_params
|
||||
@local_params = {
|
||||
title: params[:title], #标题
|
||||
body: params[:body], #内容
|
||||
head: params[:head], #源分支
|
||||
base: params[:base], #目标分支
|
||||
milestone: 0, #里程碑,未与本地的里程碑关联
|
||||
}
|
||||
@requests_params = @local_params.merge({
|
||||
assignee: current_user.try(:login),
|
||||
assignees: ["#{params[:assigned_login].to_s}"],
|
||||
labels: params[:issue_tag_ids],
|
||||
due_date: Time.now
|
||||
})
|
||||
@issue_params = {
|
||||
author_id: current_user.id,
|
||||
project_id: @project.id,
|
||||
subject: params[:title],
|
||||
description: params[:body],
|
||||
assigned_to_id: params[:assigned_to_id],
|
||||
fixed_version_id: params[:fixed_version_id],
|
||||
issue_tags_value: params[:issue_tag_ids].present? ? params[:issue_tag_ids].join(",") : "",
|
||||
priority_id: params[:priority_id] || "2",
|
||||
issue_classify: "pull_request",
|
||||
issue_type: params[:issue_type] || "1",
|
||||
tracker_id: 2,
|
||||
status_id: 1,
|
||||
}
|
||||
end
|
||||
end
|
|
@ -95,22 +95,7 @@ class RepositoriesController < ApplicationController
|
|||
end
|
||||
|
||||
def repo_hook
|
||||
hook_type = request.headers["X-Gitea-Event"].to_s # 获取推送的方式
|
||||
ownername = @project.owner.try(:login)
|
||||
reponame = @project.identifier
|
||||
username = current_user.try(:login)
|
||||
user_params = {
|
||||
"ownername": ownername,
|
||||
"username": username,
|
||||
"reponame": reponame
|
||||
}
|
||||
uploadPushInfo = hook_params(hook_type, params).merge(user_params)
|
||||
chain_params = {
|
||||
type: hook_type,
|
||||
uploadPushInfo: uploadPushInfo
|
||||
}.merge(user_params)
|
||||
ProjectCreateChainJob.perform_later(chain_params)
|
||||
@project.update_attribute(:token, @project.token + uploadPushInfo[:modificationLines].to_i)
|
||||
|
||||
end
|
||||
|
||||
def sync_mirror
|
||||
|
@ -159,27 +144,24 @@ class RepositoriesController < ApplicationController
|
|||
end
|
||||
|
||||
def hook_params(hook_type, params)
|
||||
if hook_type == "push"
|
||||
# TODO hook返回的记录中,暂时没有文件代码数量的增减,暂时根据 commits数量来计算
|
||||
uploadPushInfo = {
|
||||
"shas": params["commits"].present? ? params["commits"].map{|c| c["id"]} : "",
|
||||
"branch": params["ref"].to_s.split("/").last,
|
||||
"modificationLines": params["commits"].length
|
||||
}
|
||||
elsif hook_type == "pull_request" && params["action"].to_s == "closed" #合并请求合并后才会有上链操作
|
||||
uploadPushInfo = {
|
||||
"source_branch": params["head"]["ref"].to_s.split("/").last,
|
||||
"target_branch": params["base"]["ref"].to_s.split("/").last,
|
||||
"source_project_id": params["head"]["repo_id"].to_i, #现在是为gitea上仓库的id
|
||||
"target_project_id": params["base"]["repo_id"].to_i,
|
||||
"shas": [params["pull_request"]["merge_commit_sha"], params["pull_request"]["merge_base"]],
|
||||
"modificationLines": 1 #pull_request中没有commits数量
|
||||
}
|
||||
else
|
||||
uploadPushInfo = {}
|
||||
end
|
||||
# if hook_type == "push"
|
||||
# # TODO hook返回的记录中,暂时没有文件代码数量的增减,暂时根据 commits数量来计算
|
||||
# uploadPushInfo = {
|
||||
# "sha": params["commits"].present? ? params["commits"].last : "",
|
||||
# "branch": params["ref"].to_s.split("/").last,
|
||||
# "modification_lines": params["commits"].length
|
||||
# }
|
||||
# elsif hook_type == "pull_request" && params["action"].to_s == "closed" #合并请求合并后才会有上链操作
|
||||
# uploadPushInfo = {
|
||||
# "branch": params["base"]["ref"].to_s.split("/").last,
|
||||
# "sha": params["pull_request"]["merge_base"],
|
||||
# "modification_lines": 1 #pull_request中没有commits数量
|
||||
# }
|
||||
# else
|
||||
# uploadPushInfo = {}
|
||||
# end
|
||||
|
||||
return uploadPushInfo
|
||||
# uploadPushInfo
|
||||
end
|
||||
|
||||
def create_new_pr(params)
|
||||
|
|
|
@ -2,7 +2,7 @@ class UsersController < ApplicationController
|
|||
|
||||
before_action :load_user, only: [:show, :homepage_info, :sync_token, :sync_gitea_pwd, :projects, :watch_users, :fan_users]
|
||||
before_action :check_user_exist, only: [:show, :homepage_info,:projects, :watch_users, :fan_users]
|
||||
before_action :require_login, only: %i[me list projects]
|
||||
before_action :require_login, only: %i[me list]
|
||||
skip_before_action :check_sign, only: [:attachment_show]
|
||||
|
||||
def list
|
||||
|
@ -23,7 +23,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def watch_users
|
||||
watchers = Watcher.watching_users(@user.id).includes(:user).order("watchers.created_at asc")
|
||||
watchers = Watcher.watching_users(@user.id).includes(:user).order("watchers.created_at desc")
|
||||
if params[:search].present?
|
||||
search_user_ids = User.where(id: watchers.pluck(:watchable_id)).like(params[:search]).pluck(:id)
|
||||
watchers = watchers.where(watchable_id: search_user_ids)
|
||||
|
@ -33,7 +33,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def fan_users
|
||||
watchers = @user.watchers.includes(:user).order("watchers.created_at asc")
|
||||
watchers = @user.watchers.includes(:user).order("watchers.created_at desc")
|
||||
watchers = watchers.joins(:user).where("LOWER(concat(users.lastname, users.firstname, users.login)) LIKE ?", "%#{params[:search].split(" ").join('|')}%") if params[:search].present?
|
||||
|
||||
@watchers_count = watchers.size
|
||||
|
|
|
@ -19,22 +19,22 @@ module TagChosenHelper
|
|||
|
||||
issue_comment_users_array = join_users(issue)
|
||||
#总耗时
|
||||
cost_time(issue)
|
||||
cost_time_array = @cost_time_array
|
||||
all_cost_time = @all_cost_time
|
||||
# cost_time(issue)
|
||||
# cost_time_array = @cost_time_array
|
||||
# all_cost_time = @all_cost_time
|
||||
|
||||
#被依赖
|
||||
be_depended_issues_array = be_depended_issues(issue)
|
||||
# be_depended_issues_array = be_depended_issues(issue)
|
||||
|
||||
#依赖于
|
||||
depended_issues(issue)
|
||||
depended_issues_array = @depended_issues_array
|
||||
depended_issues_id = @depended_issues_id
|
||||
# depended_issues(issue)
|
||||
# depended_issues_array = @depended_issues_array
|
||||
# depended_issues_id = @depended_issues_id
|
||||
|
||||
end
|
||||
project_members = project.members_user_infos
|
||||
project_members_info = [] #指派给
|
||||
project_members.each do |member|
|
||||
project_members.includes(user: :user_extension).each do |member|
|
||||
user = member&.user
|
||||
if user
|
||||
real_name = user.try(:show_real_name)
|
||||
|
@ -114,14 +114,15 @@ module TagChosenHelper
|
|||
new_types_info.push(new_type_info)
|
||||
end
|
||||
|
||||
depend_other_issues = project.issues.issue_issue.where.not(id: issue_id)&.pluck(:id, :subject)
|
||||
if depend_other_issues.size > 0
|
||||
depend_other_issues.each do |t|
|
||||
is_chosen = depended_issues_id.include?(t[0]) ? "1" : "0"
|
||||
new_issue = {id: t[0], subject: t[1], is_chosen: is_chosen}
|
||||
all_issues.push(new_issue)
|
||||
end
|
||||
end
|
||||
#依赖issue暂时取消
|
||||
# depend_other_issues = project.issues.issue_issue.where.not(id: issue_id)&.pluck(:id, :subject)
|
||||
# if depend_other_issues.size > 0
|
||||
# depend_other_issues.each do |t|
|
||||
# is_chosen = depended_issues_id.include?(t[0]) ? "1" : "0"
|
||||
# new_issue = {id: t[0], subject: t[1], is_chosen: is_chosen}
|
||||
# all_issues.push(new_issue)
|
||||
# end
|
||||
# end
|
||||
|
||||
|
||||
{
|
||||
|
@ -134,10 +135,10 @@ module TagChosenHelper
|
|||
"due_date": issue_info[6],
|
||||
"joins_users": issue_comment_users_array,
|
||||
"cost_time_users": cost_time_array,
|
||||
"total_cost_time": Time.at(all_cost_time).utc.strftime('%H h %M min %S s'),
|
||||
"be_depended_issues": be_depended_issues_array,
|
||||
"depended_issues":depended_issues_array,
|
||||
"estimated_hours": issue_info[7],
|
||||
# "total_cost_time": Time.at(all_cost_time).utc.strftime('%H h %M min %S s'),
|
||||
# "be_depended_issues": be_depended_issues_array,
|
||||
# "depended_issues":depended_issues_array,
|
||||
# "estimated_hours": issue_info[7],
|
||||
"done_ratio": new_done_info,
|
||||
"issue_tag": new_tags_info,
|
||||
"issue_type": new_types_info,
|
||||
|
@ -159,49 +160,49 @@ module TagChosenHelper
|
|||
issue_comment_users_array
|
||||
end
|
||||
|
||||
def cost_time(issue)
|
||||
#总耗时
|
||||
@cost_time_array = []
|
||||
@all_cost_time = 0
|
||||
all_issue_times = issue.issue_times.includes(:user).where.not(end_time: nil)
|
||||
if issue.present? && all_issue_times.size > 0
|
||||
all_issue_times.each do |time|
|
||||
cost_time = time.end_time.to_i - time.start_time.to_i
|
||||
cost_time = cost_time > 0 ? cost_time : 0
|
||||
@all_cost_time = @all_cost_time + cost_time
|
||||
set_cost_time = Time.at(cost_time).utc.strftime('%H h %M min %S s')
|
||||
@cost_time_array.push({login: time.user.try(:login), avatar_url: url_to_avatar(time.user), cost_time: set_cost_time})
|
||||
end
|
||||
end
|
||||
end
|
||||
# def cost_time(issue)
|
||||
# #总耗时
|
||||
# @cost_time_array = []
|
||||
# @all_cost_time = 0
|
||||
# all_issue_times = issue.issue_times.includes(:user).where.not(end_time: nil)
|
||||
# if issue.present? && all_issue_times.size > 0
|
||||
# all_issue_times.each do |time|
|
||||
# cost_time = time.end_time.to_i - time.start_time.to_i
|
||||
# cost_time = cost_time > 0 ? cost_time : 0
|
||||
# @all_cost_time = @all_cost_time + cost_time
|
||||
# set_cost_time = Time.at(cost_time).utc.strftime('%H h %M min %S s')
|
||||
# @cost_time_array.push({login: time.user.try(:login), avatar_url: url_to_avatar(time.user), cost_time: set_cost_time})
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
def depended_issues(issue)
|
||||
#依赖于
|
||||
@depended_issues_id = []
|
||||
@depended_issues_array = []
|
||||
depended_issues = issue.issue_depends.pluck(:id,:depend_issue_id).uniq
|
||||
if issue.present? && depended_issues.size > 0
|
||||
depended_issues.each do |de|
|
||||
@depended_issues_id.push(de[1])
|
||||
issues = Issue.select(:id, :subject).where(id: de[1]).as_json
|
||||
issues = issues.first.merge(depend_id: de[0])
|
||||
@depended_issues_array.push(issues)
|
||||
end
|
||||
@depended_issues_id.delete(issue.id)
|
||||
end
|
||||
end
|
||||
# def depended_issues(issue)
|
||||
# #依赖于
|
||||
# @depended_issues_id = []
|
||||
# @depended_issues_array = []
|
||||
# depended_issues = issue.issue_depends.pluck(:id,:depend_issue_id).uniq
|
||||
# if issue.present? && depended_issues.size > 0
|
||||
# depended_issues.each do |de|
|
||||
# @depended_issues_id.push(de[1])
|
||||
# issues = Issue.select(:id, :subject).where(id: de[1]).as_json
|
||||
# issues = issues.first.merge(depend_id: de[0])
|
||||
# @depended_issues_array.push(issues)
|
||||
# end
|
||||
# @depended_issues_id.delete(issue.id)
|
||||
# end
|
||||
# end
|
||||
|
||||
def be_depended_issues(issue)
|
||||
be_depended_issues_array = []
|
||||
be_depended_issues = IssueDepend.where(depend_issue_id: issue.id).pluck(:id,:issue_id).uniq
|
||||
if issue.present? && be_depended_issues.size > 0
|
||||
be_depended_issues.each do |de|
|
||||
d_issues = Issue.select(:id, :subject).where(id: de[1]).as_json
|
||||
d_issues = d_issues.first.merge(depend_id: de[0])
|
||||
be_depended_issues_array.push(d_issues)
|
||||
end
|
||||
end
|
||||
be_depended_issues_array
|
||||
end
|
||||
# def be_depended_issues(issue)
|
||||
# be_depended_issues_array = []
|
||||
# be_depended_issues = IssueDepend.where(depend_issue_id: issue.id).pluck(:id,:issue_id).uniq
|
||||
# if issue.present? && be_depended_issues.size > 0
|
||||
# be_depended_issues.each do |de|
|
||||
# d_issues = Issue.select(:id, :subject).where(id: de[1]).as_json
|
||||
# d_issues = d_issues.first.merge(depend_id: de[0])
|
||||
# be_depended_issues_array.push(d_issues)
|
||||
# end
|
||||
# end
|
||||
# be_depended_issues_array
|
||||
# end
|
||||
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
class ChangeTokenJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(change_params)
|
||||
status = 0
|
||||
5.times do |i|
|
||||
if status == 200
|
||||
Rails.logger.info("########_change_user_toke_success_user:__#{change_params[:username]}_try:_#{i+1}_")
|
||||
break
|
||||
else
|
||||
Rails.logger.info("########_change_user_toke_try:_#{i+1}_")
|
||||
chain_status = `chain #{change_params[:change_type]} #{change_params[:ownername]} #{change_params[:reponame]} #{change_params[:username]} #{change_params[:tokens].to_i}`
|
||||
chain_status = eval(chain_status)
|
||||
status = chain_status[:status].to_i
|
||||
end
|
||||
end
|
||||
unless status == 200
|
||||
Rails.logger.info("########_change_user_toke_failed__change_params:__#{change_params}_")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,46 +0,0 @@
|
|||
class ProjectCreateChainJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(chain_params)
|
||||
status = false
|
||||
chain_type = chain_params[:type].to_s
|
||||
reponame = chain_params[:reponame]
|
||||
|
||||
5.times do |i|
|
||||
if status
|
||||
Rails.logger.info("########_repository__#{reponame}______create_chain_success__try:_#{i+1}_")
|
||||
break
|
||||
else
|
||||
Rails.logger.info("########_repository__#{reponame}______start_to_create_chain__try:_#{i+1}_")
|
||||
if chain_type == "create"
|
||||
chain_status = create_chain(chain_params)
|
||||
elsif chain_type == "push"
|
||||
chain_status = push_chain(chain_params)
|
||||
else
|
||||
chain_status = {status: 200}
|
||||
end
|
||||
Rails.logger.info("########_response__chain_status__#{chain_status}__")
|
||||
|
||||
status = chain_status[:status].to_i
|
||||
end
|
||||
end
|
||||
|
||||
unless status == 200
|
||||
Rails.logger.info("########_repository__#{reponame}__create_chain:___#{chain_status}____failed_to_create_chain__")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
#创建项目的上链操作
|
||||
def create_chain(chain_params)
|
||||
result = `chain trustieCreate #{chain_params[:ownername]} #{chain_params[:reponame]}`
|
||||
return eval(result)
|
||||
end
|
||||
|
||||
# push项目的上链操作
|
||||
def push_chain(chain_params)
|
||||
result = `chain trustiePush #{chain_params[:ownername]} #{chain_params[:reponame]} #{chain_params[:username]} #{chain_params[:uploadPushInfo]}`
|
||||
return eval(result)
|
||||
end
|
||||
end
|
|
@ -22,14 +22,14 @@ class Issue < ApplicationRecord
|
|||
scope :issue_many_includes, ->{includes(journals: :user)}
|
||||
scope :issue_issue, ->{where(issue_classify: [nil,"issue"])}
|
||||
scope :issue_pull_request, ->{where(issue_classify: "pull_request")}
|
||||
scope :issue_index_includes, ->{includes(:user,:tracker, :priority, :version, :issue_status, :journals, :issue_times)}
|
||||
scope :issue_index_includes, ->{includes(:tracker, :priority, :version, :issue_status, :journals,:issue_tags,user: :user_extension)}
|
||||
|
||||
after_update :change_versions_count
|
||||
after_destroy :update_closed_issues_count_in_project!
|
||||
|
||||
|
||||
def get_assign_user
|
||||
User.select(:login, :lastname,:firstname, :nickname)&.find_by_id(self.assigned_to_id)
|
||||
User&.find_by_id(self.assigned_to_id) if self.assigned_to_id.present?
|
||||
end
|
||||
|
||||
def create_journal_detail(change_files, issue_files, issue_file_ids, user_id)
|
||||
|
|
|
@ -24,12 +24,12 @@ class Project < ApplicationRecord
|
|||
has_one :project_score, dependent: :destroy
|
||||
has_one :repository, dependent: :destroy
|
||||
has_many :pull_requests, dependent: :destroy
|
||||
has_many :issue_tags, dependent: :destroy
|
||||
has_many :issue_tags, -> { order("issue_tags.created_at DESC") }, dependent: :destroy
|
||||
has_many :issues, dependent: :destroy
|
||||
# has_many :user_grades, dependent: :destroy
|
||||
has_many :attachments, as: :container, dependent: :destroy
|
||||
has_one :project_score, dependent: :destroy
|
||||
has_many :versions, -> { order("versions.effective_date DESC, versions.name DESC") }, dependent: :destroy
|
||||
has_many :versions, -> { order("versions.created_on DESC, versions.name DESC") }, dependent: :destroy
|
||||
has_many :praise_treads, as: :praise_tread_object, dependent: :destroy
|
||||
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
||||
|
||||
|
|
|
@ -17,6 +17,12 @@ class Projects::ListMyQuery < ApplicationQuery
|
|||
projects = Project.visible
|
||||
end
|
||||
|
||||
if params[:is_public].present? && params[:is_public] == "private"
|
||||
projects = projects.is_private.joins(:members).where(members: { user_id: user.id })
|
||||
else
|
||||
projects = projects.visible.joins(:members).where(members: { user_id: user.id })
|
||||
end
|
||||
|
||||
if params[:category].blank?
|
||||
projects = projects.joins(:members).where(members: { user_id: user.id })
|
||||
elsif params[:category].to_s == "join"
|
||||
|
@ -28,10 +34,10 @@ class Projects::ListMyQuery < ApplicationQuery
|
|||
elsif params[:category].to_s == "forked" #我fork的
|
||||
fork_ids = user.fork_users.select(:id, :fork_project_id).pluck(:fork_project_id)
|
||||
projects = projects.where(id: fork_ids)
|
||||
elsif params[:category].to_s == "public"
|
||||
projects = projects.visible.joins(:members).where(members: { user_id: user.id })
|
||||
elsif params[:category].to_s == "private"
|
||||
projects = projects.is_private.joins(:members).where(members: { user_id: user.id })
|
||||
# elsif params[:category].to_s == "public"
|
||||
# projects = projects.visible.joins(:members).where(members: { user_id: user.id })
|
||||
# elsif params[:category].to_s == "private"
|
||||
# projects = projects.is_private.joins(:members).where(members: { user_id: user.id })
|
||||
end
|
||||
|
||||
if params[:project_type].to_s === "common"
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
class Gitea::Repository::Hooks::QueryService < Gitea::ClientService
|
||||
#查询用户的积分/贡献
|
||||
#query_params = {
|
||||
#type: "user", #"user/members/percent"
|
||||
#ownername: ownername,
|
||||
#reponame: reponame,
|
||||
#username: username
|
||||
#}
|
||||
attr_reader :query_params
|
||||
|
||||
def initialize(query_params)
|
||||
@query_params = query_params
|
||||
end
|
||||
|
||||
def call
|
||||
query_type = query_params[:type] || "user"
|
||||
if query_type == "user" #查询单个用户的积分
|
||||
query_result = `chain query #{query_params[:ownername]} #{query_params[:reponame]} #{query_params[:username]}`
|
||||
|
||||
#response {status:int, message:string, value:int}
|
||||
elsif query_type == "members" #查询项目全部用户的积分
|
||||
query_result = `chain getAllInfo #{query_params[:ownername]} #{query_params[:reponame]}`
|
||||
#response {status:int, message:string, value:jsonObject}
|
||||
else #查询用户在项目的贡献大小
|
||||
query_result = `chain getContributionPercent #{query_params[:ownername]} #{query_params[:reponame]} #{query_params[:username]}`
|
||||
|
||||
#response {status:int, message:string, percent:int, allTokenSum:int, personalTokens:int}
|
||||
end
|
||||
eval(query_result)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,10 +1,11 @@
|
|||
class Issues::ListQueryService < ApplicationService
|
||||
|
||||
attr_reader :all_issues, :params
|
||||
attr_reader :all_issues, :params,:select_type
|
||||
|
||||
def initialize(all_issues, params)
|
||||
def initialize(all_issues, params, select_type)
|
||||
@all_issues = all_issues
|
||||
@params = params
|
||||
@select_type = select_type
|
||||
end
|
||||
|
||||
def call
|
||||
|
@ -17,7 +18,13 @@ class Issues::ListQueryService < ApplicationService
|
|||
if status_type.to_s == "2" #表示关闭中的
|
||||
issues = issues.where(status_id: 5)
|
||||
elsif status_type.to_s == "1"
|
||||
issues = issues.where.not(status_id: 5) #默认显示开启中的
|
||||
if(select_type == "Issue")
|
||||
issues = issues.where.not(status_id: 5) #默认显示开启中的
|
||||
else
|
||||
issues = issues.joins(:pull_request).where(pull_requests: {status: 0}) #默认显示开启中的
|
||||
end
|
||||
elsif status_type.to_s == "11" #表示pr的已关闭
|
||||
issues = issues.joins(:pull_request).where(pull_requests: {status: 1})
|
||||
end
|
||||
|
||||
if search_name.present?
|
||||
|
|
|
@ -7,9 +7,12 @@ class Projects::CreateService < ApplicationService
|
|||
end
|
||||
|
||||
def call
|
||||
Rails.logger.info("#############__________project_params______###########{project_params}")
|
||||
|
||||
@project = Project.new(project_params)
|
||||
ActiveRecord::Base.transaction do
|
||||
if @project.save!
|
||||
Rails.logger.info("#############___________repository_params______###########{repository_params}")
|
||||
Repositories::CreateService.new(user, @project, repository_params).call
|
||||
else
|
||||
#
|
||||
|
@ -39,17 +42,17 @@ class Projects::CreateService < ApplicationService
|
|||
|
||||
def repository_params
|
||||
{
|
||||
hidden: get_is_public,
|
||||
hidden: !repo_is_public,
|
||||
user_id: params[:user_id],
|
||||
identifier: params[:repository_name]
|
||||
}
|
||||
end
|
||||
|
||||
def get_is_public
|
||||
params[:private] || true
|
||||
end
|
||||
# def get_is_public
|
||||
# params[:private] || false
|
||||
# end
|
||||
|
||||
def repo_is_public
|
||||
params[:private].blank? ? true : !get_is_public
|
||||
params[:private].blank? ? true : !params[:private]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,19 +11,11 @@ class Repositories::CreateService < ApplicationService
|
|||
@repository = Repository.new(repository_params)
|
||||
ActiveRecord::Base.transaction do
|
||||
if @repository.save!
|
||||
Rails.logger.info("#############__________gitea_repository_params______###########{gitea_repository_params}")
|
||||
|
||||
gitea_repository = Gitea::Repository::CreateService.new(user.gitea_token, gitea_repository_params).call
|
||||
sync_project(@repository, gitea_repository)
|
||||
sync_repository(@repository, gitea_repository)
|
||||
if project.project_type == "common"
|
||||
|
||||
chain_params = {
|
||||
type: "create",
|
||||
ownername: user.try(:login),
|
||||
reponame: @repository.try(:id)
|
||||
}
|
||||
# ProjectCreateChainJob.perform_later(chain_params) #创建上链操作
|
||||
|
||||
end
|
||||
end
|
||||
@repository
|
||||
end
|
||||
|
|
|
@ -1 +1,16 @@
|
|||
json.partial! 'users/user', user: @user
|
||||
# json.partial! 'users/user', user: @user
|
||||
|
||||
json.username @user.full_name
|
||||
json.real_name @user.real_name
|
||||
json.login @user.login
|
||||
json.user_id @user.id
|
||||
json.image_url url_to_avatar(@user)
|
||||
json.admin @user.admin?
|
||||
json.user_identity @user.identity
|
||||
json.is_watch current_user&.watched?(@user)
|
||||
# json.watched_count @user.fan_count #粉丝
|
||||
# json.watching_count @user.follow_count #关注数
|
||||
# json.undo_events @undo_events
|
||||
# json.user_composes_count @user_composes_count
|
||||
# json.common_projects_count @projects_common_count
|
||||
# json.mirror_projects_count @projects_mirrior_count
|
|
@ -10,7 +10,7 @@ json.user_admin_or_member @user_admin_or_member
|
|||
|
||||
json.issues do
|
||||
json.array! @issues.to_a do |issue|
|
||||
cost_time(issue)
|
||||
# cost_time(issue)
|
||||
json.id issue.id
|
||||
json.name issue.subject
|
||||
json.format_time format_time(issue.created_on)
|
||||
|
@ -31,6 +31,6 @@ json.issues do
|
|||
json.token issue.issue_type == "2" ? issue.token : ""
|
||||
json.issue_classify issue.issue_classify
|
||||
json.branch_name issue.branch_name
|
||||
json.cost_time @all_cost_time
|
||||
# json.cost_time @all_cost_time
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,10 +18,10 @@ json.done_ratio @issue.done_ratio.to_s + "%"
|
|||
json.issue_type @issue.issue_type
|
||||
json.token @issue.issue_type == "2" ? @issue.token : ""
|
||||
json.join_users @join_users
|
||||
json.cost_time @cost_time_array
|
||||
json.total_cost_time Time.at(@all_cost_time).utc.strftime('%H h %M min %S s')
|
||||
json.be_depended_issues @be_depended_issues_array
|
||||
json.depended_issues @depended_issues_array
|
||||
# json.cost_time @cost_time_array
|
||||
# json.total_cost_time Time.at(@all_cost_time).utc.strftime('%H h %M min %S s')
|
||||
# json.be_depended_issues @be_depended_issues_array
|
||||
# json.depended_issues @depended_issues_array
|
||||
json.issue_classify @issue.issue_classify
|
||||
json.branch_name @issue.branch_name
|
||||
json.journals_count @issue.get_journals_size
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
json.issue_tags @project_tags
|
||||
json.issue_versions @project_versions
|
||||
json.issue_priories @project_priories
|
||||
json.project_author @project.owner.try(:show_real_name)
|
||||
json.project_name @project.try(:name)
|
||||
json.members do
|
||||
json.array! @project_members.to_a.each do |member|
|
||||
json.id member.user_id
|
||||
json.login member.user.try(:login)
|
||||
json.name member.user.try(:show_real_name)
|
||||
json.avatar_url url_to_avatar(member.user)
|
||||
end
|
||||
end
|
|
@ -1,18 +1,5 @@
|
|||
json.partial! "commons/success"
|
||||
json.pull_request do
|
||||
json.extract! @pull_request, :id,:base, :head, :status
|
||||
end
|
||||
|
||||
json.issue do
|
||||
json.extract! @issue, :id,:subject,:description,:is_private,:assigned_to_id,:tracker_id,:status_id,:priority_id,:fixed_version_id,
|
||||
:start_date,:due_date,:estimated_hours, :issue_type, :token,:issue_classify, :branch_name
|
||||
json.done_ratio @issue.done_ratio.to_s + "%"
|
||||
json.issue_tags @issue.get_issue_tags
|
||||
json.issue_chosen @issue_chosen
|
||||
end
|
||||
|
||||
json.attachments do
|
||||
json.array! @issue_attachments do |attachment|
|
||||
json.partial! "attachments/attachment_simple", locals: {attachment: attachment}
|
||||
end
|
||||
end
|
||||
json.partial! "pull_requests/merge_item"
|
||||
json.extract! @pull_request, :id, :title, :body, :milestone,:head,:base
|
||||
json.extract! @issue, :assigned_to_id, :fixed_version_id, :priority_id
|
||||
json.issue_tag_ids @issue.issue_tags_value.split(",")
|
||||
|
|
|
@ -2,39 +2,33 @@ json.partial! "commons/success"
|
|||
json.all_count @all_issues_size
|
||||
json.open_count @open_issues_size
|
||||
json.close_count @close_issues_size
|
||||
json.assign_me_count @assign_to_me_size
|
||||
json.my_published_count @my_published_size
|
||||
json.merged_issues_size @merged_issues_size
|
||||
json.search_count @issues_size
|
||||
json.limit @limit
|
||||
json.user_admin_or_member @user_admin_or_member
|
||||
json.project_name @project.name
|
||||
|
||||
json.issues do
|
||||
json.array! @issues.to_a do |issue|
|
||||
cost_time(issue)
|
||||
json.pull_request_id issue.pull_request.id
|
||||
json.pull_request_status issue.pull_request.status
|
||||
pr = issue.pull_request
|
||||
json.pull_request_id pr.id
|
||||
json.pull_request_status pr.status
|
||||
json.pull_request_head pr.head
|
||||
json.pull_request_base pr.base
|
||||
json.pull_request_staus pr.status == 1 ? "merged" : (pr.status == 2 ? "closed" : "open")
|
||||
|
||||
json.id issue.id
|
||||
json.name issue.subject
|
||||
json.format_time format_time(issue.created_on)
|
||||
json.created_at time_from_now(issue.created_on)
|
||||
json.updated_at format_time(issue.updated_on)
|
||||
json.pr_time time_from_now(pr.status == 1 ? pr.updated_at : issue.updated_on)
|
||||
json.assign_user_name issue.get_assign_user.try(:show_real_name)
|
||||
json.assign_user_login issue.get_assign_user.try(:login)
|
||||
json.author_name issue.user.try(:show_real_name)
|
||||
json.author_login issue.user.try(:login)
|
||||
json.tracker issue.tracker.try(:name)
|
||||
json.issue_status issue.issue_status.try(:name)
|
||||
json.avatar_url url_to_avatar(issue.user)
|
||||
json.priority issue.priority.try(:name)
|
||||
json.version issue.version.try(:name)
|
||||
json.done_ratio issue.done_ratio.to_s + "%"
|
||||
json.journals_count issue.get_journals_size
|
||||
json.issue_tags issue.get_issue_tags
|
||||
json.issue_type issue.issue_type == "1" ? "普通" : "悬赏"
|
||||
json.token issue.issue_type == "2" ? issue.token : ""
|
||||
json.issue_classify issue.issue_classify
|
||||
json.branch_name issue.branch_name
|
||||
json.cost_time @all_cost_time
|
||||
end
|
||||
end
|
||||
|
||||
# json.issues @issues
|
||||
|
|
|
@ -1,13 +1,3 @@
|
|||
json.partial! "commons/success"
|
||||
json.partial! "pull_requests/merge_item"
|
||||
json.branches @all_branches
|
||||
json.issue_tags @project_tags
|
||||
json.issue_versions @project_versions
|
||||
|
||||
json.members do
|
||||
json.array! @project_members.to_a.each do |member|
|
||||
json.id member.user_id
|
||||
json.login member.user.try(:login)
|
||||
json.name member.user.try(:show_real_name)
|
||||
json.avatar_url url_to_avatar(member.user)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
json.partial! "commons/success"
|
||||
json.project_name @project.name
|
||||
json.pr_time time_from_now(@pull_request.updated_at)
|
||||
json.pull_request do
|
||||
json.extract! @pull_request, :id,:base, :head, :status, :gpid
|
||||
json.extract! @pull_request, :id,:base, :head, :status
|
||||
json.pull_request_staus @pull_request.status == 1 ? "merged" : (@pull_request.status == 2 ? "closed" : "open")
|
||||
end
|
||||
|
||||
json.issue do
|
||||
json.extract! @issue, :id,:subject,:is_lock,:description,:is_private, :start_date,:due_date,:estimated_hours,:issue_classify, :branch_name
|
||||
|
||||
json.extract! @issue, :id,:subject,:description,:is_private, :branch_name
|
||||
json.user_permission @user_permission
|
||||
json.closed_on @issue.closed_on.present? ? format_time(@issue.closed_on) : ""
|
||||
json.created_at format_time(@issue.created_on)
|
||||
|
@ -14,27 +16,13 @@ json.issue do
|
|||
json.author_name @issue_user.try(:show_real_name)
|
||||
json.author_login @issue_user.try(:login)
|
||||
json.author_picture url_to_avatar(@issue_user)
|
||||
json.tracker @issue.tracker.try(:name)
|
||||
json.issue_status @issue.issue_status.try(:name)
|
||||
json.priority @issue.priority.try(:name)
|
||||
json.version @issue.version.try(:name)
|
||||
json.issue_tags @issue.get_issue_tags
|
||||
json.done_ratio @issue.done_ratio.to_s + "%"
|
||||
json.issue_type @issue.issue_type == "1" ? "普通" : "悬赏"
|
||||
json.token @issue.issue_type == "2" ? @issue.token : ""
|
||||
json.join_users @join_users
|
||||
json.cost_time @cost_time_array
|
||||
json.total_cost_time Time.at(@all_cost_time).utc.strftime('%H h %M min %S s')
|
||||
json.be_depended_issues @be_depended_issues_array
|
||||
json.depended_issues @depended_issues_array
|
||||
end
|
||||
|
||||
json.attachments do
|
||||
json.array! @issue_attachments do |attachment|
|
||||
json.partial! "attachments/attachment_simple", locals: {attachment: attachment}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ json.identifier @project.identifier
|
|||
json.name @project.name
|
||||
json.project_id @project.id
|
||||
json.repo_id @project.repository.id
|
||||
json.issues_count @project.issues_count
|
||||
json.issues_count @project.issues_count.to_i - @project.pull_requests_count.to_i
|
||||
json.pull_requests_count @project.pull_requests_count
|
||||
json.project_identifier @project.identifier
|
||||
json.praises_count @project.praises_count.to_i
|
||||
|
|
|
@ -13,7 +13,7 @@ json.extract! @version, :id,:name,:project_id,:description, :effective_date, :st
|
|||
|
||||
json.issues do
|
||||
json.array! @version_issues.each.to_a do |issue|
|
||||
cost_time(issue)
|
||||
# cost_time(issue)
|
||||
json.id issue.id
|
||||
json.name issue.subject
|
||||
json.format_time format_time(issue.created_on)
|
||||
|
@ -34,7 +34,7 @@ json.issues do
|
|||
json.token issue.issue_type == "2" ? issue.token : ""
|
||||
json.issue_classify issue.issue_classify
|
||||
json.branch_name issue.branch_name
|
||||
json.cost_time @all_cost_time
|
||||
# json.cost_time @all_cost_time
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -64,8 +64,8 @@ Rails.application.routes.draw do
|
|||
resources :pull_requests, except: [:destroy] do
|
||||
member do
|
||||
post :pr_merge
|
||||
post :check_merge
|
||||
post :simple_update
|
||||
# post :check_merge
|
||||
post :refuse_merge
|
||||
end
|
||||
collection do
|
||||
post :check_can_merge
|
||||
|
|
Loading…
Reference in New Issue