Merge branch 'dev_trustie' of http://gitea.trustie.net/jasder/forgeplus into dev_trustie

This commit is contained in:
Jasder
2020-06-23 11:57:35 +08:00
30 changed files with 258 additions and 552 deletions
@@ -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
+10 -3
View File
@@ -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?
+8 -5
View File
@@ -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
+2 -10
View File
@@ -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