mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
Merge branch 'standalone_develop' into pm_project_develop
This commit is contained in:
@@ -76,10 +76,22 @@ class Api::V1::Issues::ListService < ApplicationService
|
||||
issues = issues.where(author_id: author_id) if author_id.present?
|
||||
|
||||
# issue_tag_ids
|
||||
issues = issues.ransack(issue_tags_value_cont: issue_tag_ids.sort!.join(',')).result unless issue_tag_ids.blank?
|
||||
if issue_tag_ids.present?
|
||||
if issue_tag_ids.include?('-1')
|
||||
issues = issues.where(issue_tags_value: nil).or(issues.where(issue_tags_value: ""))
|
||||
else
|
||||
issues = issues.ransack(issue_tags_value_cont: issue_tag_ids.sort!.join(',')).result
|
||||
end
|
||||
end
|
||||
|
||||
# milestone_id
|
||||
issues = issues.where(fixed_version_id: milestone_id) if milestone_id.present?
|
||||
if milestone_id.present?
|
||||
if milestone_id.to_i == -1
|
||||
issues = issues.where(fixed_version_id: nil)
|
||||
else
|
||||
issues = issues.where(fixed_version_id: milestone_id)
|
||||
end
|
||||
end
|
||||
|
||||
#pm相关
|
||||
# root_id# -1 查一级目录
|
||||
@@ -102,7 +114,13 @@ class Api::V1::Issues::ListService < ApplicationService
|
||||
issues = issues.where(pm_sprint_id: pm_sprint_id) if pm_sprint_id.present?
|
||||
|
||||
# assigner_id
|
||||
issues = issues.joins(:assigners).where(users: {id: assigner_id}) if assigner_id.present?
|
||||
if assigner_id.present?
|
||||
if assigner_id.to_i == -1
|
||||
issues = issues.left_joins(:assigners).where(users: {id: nil})
|
||||
else
|
||||
issues = issues.joins(:assigners).where(users: {id: assigner_id})
|
||||
end
|
||||
end
|
||||
|
||||
# status_id
|
||||
issues = issues.where(status_id: status_id) if status_id.present? && category != 'closed'
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
class Api::V1::Projects::Actions::Runs::JobShowService < ApplicationService
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_reader :project, :token, :owner, :repo, :run, :job, :log_cursors
|
||||
attr_accessor :gitea_data
|
||||
|
||||
validates :run, :job, :log_cursors, presence: true
|
||||
|
||||
def initialize(project, run, job, log_cursors, token = nil)
|
||||
@project = project
|
||||
@owner = project&.owner.login
|
||||
@repo = project&.identifier
|
||||
@run = run
|
||||
@job = job
|
||||
@log_cursors = log_cursors
|
||||
@token = token
|
||||
end
|
||||
|
||||
def call
|
||||
raise Error, errors.full_messages.join(",") unless valid?
|
||||
load_gitea_data
|
||||
|
||||
@gitea_data
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def request_body
|
||||
{
|
||||
logCursors: log_cursors
|
||||
}
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_hat_client.post_repos_actions_runs_jobs_by_owner_repo_run_job(owner, repo, run, job, {query: request_params, body: request_body.to_json})
|
||||
end
|
||||
end
|
||||
40
app/services/api/v1/projects/actions/runs/list_service.rb
Normal file
40
app/services/api/v1/projects/actions/runs/list_service.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
class Api::V1::Projects::Actions::Runs::ListService < ApplicationService
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_reader :project, :token, :owner, :repo, :workflow, :page, :limit
|
||||
attr_accessor :gitea_data
|
||||
|
||||
validates :workflow, presence: true
|
||||
|
||||
def initialize(project, params, token =nil)
|
||||
@project = project
|
||||
@owner = project&.owner.login
|
||||
@repo = project&.identifier
|
||||
@workflow = params[:workflow]
|
||||
@page = params[:page] || 1
|
||||
@limit = params[:limit] || 15
|
||||
@token = token
|
||||
end
|
||||
|
||||
def call
|
||||
raise Error, errors.full_messages.join(",") unless valid?
|
||||
load_gitea_data
|
||||
|
||||
@gitea_data
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token,
|
||||
workflow: workflow,
|
||||
page: page,
|
||||
limit: limit
|
||||
}
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_hat_client.get_repos_actions_by_owner_repo(owner, repo, {query: request_params}) rescue nil
|
||||
raise Error, '获取流水线执行记录失败!' unless @gitea_data.is_a?(Hash)
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
class Api::V1::Projects::Branches::ListService < ApplicationService
|
||||
|
||||
attr_accessor :project, :token, :owner, :repo, :name, :page, :limit
|
||||
attr_accessor :project, :token, :owner, :repo, :name, :state, :page, :limit
|
||||
attr_accessor :gitea_data, :gitea_repo_data
|
||||
|
||||
def initialize(project, params, token=nil)
|
||||
@@ -9,6 +9,7 @@ class Api::V1::Projects::Branches::ListService < ApplicationService
|
||||
@repo = project&.identifier
|
||||
@token = token
|
||||
@name = params[:name]
|
||||
@state = params[:state]
|
||||
@page = params[:page]
|
||||
@limit = params[:limit]
|
||||
end
|
||||
@@ -18,7 +19,6 @@ class Api::V1::Projects::Branches::ListService < ApplicationService
|
||||
load_default_branch
|
||||
|
||||
@gitea_data[:default_branch] = @gitea_repo_data["default_branch"]
|
||||
|
||||
@gitea_data
|
||||
end
|
||||
|
||||
@@ -30,7 +30,8 @@ class Api::V1::Projects::Branches::ListService < ApplicationService
|
||||
limit: limit
|
||||
}
|
||||
params.merge!({name: name}) if name.present?
|
||||
|
||||
params.merge!({state: state}) if state.present?
|
||||
|
||||
params
|
||||
end
|
||||
|
||||
|
||||
47
app/services/api/v1/projects/branches/restore_service.rb
Normal file
47
app/services/api/v1/projects/branches/restore_service.rb
Normal file
@@ -0,0 +1,47 @@
|
||||
class Api::V1::Projects::Branches::RestoreService < ApplicationService
|
||||
|
||||
include ActiveModel::Model
|
||||
|
||||
attr_accessor :project, :token, :owner, :repo, :branch_id, :branch_name
|
||||
attr_accessor :gitea_data
|
||||
|
||||
validates :branch_id, :branch_name, presence: true
|
||||
|
||||
def initialize(project, branch_id, branch_name, token= nil)
|
||||
@project = project
|
||||
@owner = project&.owner&.login
|
||||
@repo = project&.identifier
|
||||
@branch_id = branch_id
|
||||
@branch_name = branch_name
|
||||
@token = token
|
||||
end
|
||||
|
||||
def call
|
||||
raise Error, errors.full_messages.join(",") unless valid?
|
||||
excute_data_to_gitea
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
{
|
||||
access_token: token
|
||||
}
|
||||
end
|
||||
|
||||
def request_body
|
||||
{
|
||||
branch_id: branch_id,
|
||||
name: branch_name,
|
||||
}
|
||||
end
|
||||
|
||||
def excute_data_to_gitea
|
||||
begin
|
||||
@gitea_data = $gitea_hat_client.post_repos_branches_restore_by_owner_repo(owner, repo, {query: request_params, body: request_body.to_json})
|
||||
rescue => e
|
||||
raise Error, '恢复分支失败!'
|
||||
end
|
||||
end
|
||||
end
|
||||
37
app/services/api/v1/projects/commits/recent_service.rb
Normal file
37
app/services/api/v1/projects/commits/recent_service.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
class Api::V1::Projects::Commits::RecentService < ApplicationService
|
||||
|
||||
attr_reader :project, :page, :limit, :owner, :repo, :token
|
||||
attr_accessor :gitea_data
|
||||
|
||||
def initialize(project, params, token=nil)
|
||||
@project = project
|
||||
@page = params[:page] || 1
|
||||
@limit = params[:limit] || 15
|
||||
@owner = project&.owner&.login
|
||||
@repo = project&.identifier
|
||||
@token = token
|
||||
end
|
||||
|
||||
def call
|
||||
load_gitea_data
|
||||
|
||||
gitea_data
|
||||
end
|
||||
|
||||
private
|
||||
def request_params
|
||||
param = {
|
||||
access_token: token,
|
||||
page: page,
|
||||
limit: limit
|
||||
}
|
||||
|
||||
param
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_hat_client.get_repos_recent_commits_by_owner_repo(owner, repo, {query: request_params}) rescue nil
|
||||
raise Error, "获取最近提交列表失败" unless @gitea_data.is_a?(Hash)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -29,6 +29,6 @@ class Api::V1::Projects::CompareService < ApplicationService
|
||||
end
|
||||
|
||||
def load_gitea_data
|
||||
@gitea_data = $gitea_client.get_repos_compare_by_owner_repo_from_to(owner, repo, from, to, {query: request_params}) rescue nil
|
||||
@gitea_data = $gitea_hat_client.get_repos_compare_by_owner_repo_baseref_headref(owner, repo, to, from, {query: request_params}) rescue nil
|
||||
end
|
||||
end
|
||||
221
app/services/baidu/tongji_service.rb
Normal file
221
app/services/baidu/tongji_service.rb
Normal file
@@ -0,0 +1,221 @@
|
||||
module Baidu
|
||||
class TongjiService < ApplicationService
|
||||
attr_reader :client_id, :client_secret, :site_id
|
||||
# login、code、password、password_confirmation
|
||||
def initialize
|
||||
@client_id = "6dMO2kqKUaMZkBrMaUMxQSNAT49v0Mjq"
|
||||
@client_secret = "qvWqF33AOmGs1tPCgsROvis9EQCuNmd3"
|
||||
@site_id = 18657013
|
||||
end
|
||||
|
||||
def call
|
||||
|
||||
end
|
||||
|
||||
|
||||
def init_overview_data_by(start_date = nil, end_date = nil)
|
||||
start_date = Time.now.prev_year.beginning_of_year if start_date.nil?
|
||||
end_date = Time.now
|
||||
Rails.logger.info("*********开始百度统计-概览:#{start_date}-#{end_date}*********")
|
||||
sql_connection = ActiveRecord::Base.connection
|
||||
sql_connection.begin_db_transaction
|
||||
|
||||
# 如果存在数据 先清空
|
||||
# sql_connection.execute("delete from daily_platform_statistics where date between '#{start_date}' and '#{end_date}'")
|
||||
multiple_days_data = overview_multiple_days_data(start_date, end_date)
|
||||
if multiple_days_data.present?
|
||||
sql = "replace into daily_platform_statistics (date,pv,visitor,ip,created_at,updated_at) values #{multiple_days_data.join(",")}"
|
||||
sql_connection.execute(sql)
|
||||
end
|
||||
sql_connection.commit_db_transaction
|
||||
Rails.logger.info("*********结束百度统计-概览:#{start_date}-#{end_date}*********")
|
||||
end
|
||||
|
||||
def init_source_from_data_by(start_date = nil, end_date = nil)
|
||||
start_date = Time.now.prev_year.beginning_of_year if start_date.nil?
|
||||
end_date = Time.now
|
||||
Rails.logger.info("*********开始百度统计-来源:#{start_date}-#{end_date}*********")
|
||||
source_from_batch_add(start_date, end_date)
|
||||
Rails.logger.info("*********结束百度统计-来源:#{start_date}-#{end_date}*********")
|
||||
end
|
||||
|
||||
# 按日期获取来源数据
|
||||
def source_from_batch_add(start_date,end_date)
|
||||
# 补充更新开始时间的当天数据
|
||||
source_from_by_date(start_date)
|
||||
diff_days(start_date, end_date).times.each do |t|
|
||||
new_start_date = start_date + (t + 1).days
|
||||
source_from_by_date(new_start_date)
|
||||
end
|
||||
# 补充更新最后时间一天数据
|
||||
source_from_by_date(end_date)
|
||||
end
|
||||
|
||||
# 按天获取来源数据
|
||||
def source_from_by_date(start_date)
|
||||
return [] unless access_token.present? && start_date.present?
|
||||
source_from_data = api("source/all/a", start_date, start_date, "pv_count,visitor_count,ip_count")
|
||||
source_from = []
|
||||
source_from_data['items'][1].each_with_index do |source, index|
|
||||
source_from.push(((source[0].to_f / source_from_data['sum'][0][0].to_f) * 100).round(2))
|
||||
end
|
||||
daily_statistic = DailyPlatformStatistic.find_or_initialize_by(date: start_date)
|
||||
daily_statistic.source_through = source_from[0]
|
||||
daily_statistic.source_link = source_from[1]
|
||||
daily_statistic.source_search = source_from[2]
|
||||
daily_statistic.source_custom = source_from[3]
|
||||
daily_statistic.save
|
||||
end
|
||||
|
||||
def diff_days(start_date, end_date)
|
||||
(end_date.beginning_of_day.to_i - start_date.beginning_of_day.to_i) / (24 * 3600)
|
||||
end
|
||||
|
||||
def overview_batch_add(start_date, end_date)
|
||||
return [] unless access_token.present? && start_date.present? && end_date.present?
|
||||
start_date = Time.now - 1.days if start_date.strftime("%Y%m%d") == end_date.strftime("%Y%m%d")
|
||||
overview_data = api("overview/getTimeTrendRpt", start_date, end_date, "pv_count,visitor_count,ip_count")
|
||||
overview_data['items'][0].each_with_index do |date, index|
|
||||
pv = overview_data['items'][1][index][0]
|
||||
visitor = overview_data['items'][1][index][1]
|
||||
ip = overview_data['items'][1][index][2]
|
||||
job_date = date[0].to_s.gsub("/", "-")
|
||||
daily_statistic = DailyPlatformStatistic.find_or_initialize_by(date: job_date)
|
||||
daily_statistic.date = job_date
|
||||
daily_statistic.pv = pv
|
||||
daily_statistic.visitor = visitor
|
||||
daily_statistic.ip = ip
|
||||
daily_statistic.save
|
||||
end
|
||||
overview_data
|
||||
end
|
||||
|
||||
def overview_multiple_days_data(start_date, end_date)
|
||||
return [] unless access_token.present? && start_date.present? && end_date.present?
|
||||
overview_data = api("overview/getTimeTrendRpt", start_date, end_date, "pv_count,visitor_count,ip_count")
|
||||
data = []
|
||||
created_at = Time.now.strftime("%Y-%m-%d 00:00:00")
|
||||
overview_data['items'][0].each_with_index do |date, index|
|
||||
pv = overview_data['items'][1][index][0]
|
||||
visitor = overview_data['items'][1][index][1]
|
||||
ip = overview_data['items'][1][index][2]
|
||||
data.push("('#{date[0].to_s.gsub("/", "-")}', #{pv.to_s.gsub("--","0")}, #{visitor.to_s.gsub("--","0")}, #{ip.to_s.gsub("--","0")},\"#{created_at}\",\"#{created_at}\")")
|
||||
end
|
||||
data
|
||||
end
|
||||
|
||||
def code_url
|
||||
"http://openapi.baidu.com/oauth/2.0/authorize?response_type=code&client_id=#{client_id}&redirect_uri=oob&scope=basic&display=popup"
|
||||
end
|
||||
|
||||
def oauth_url(code)
|
||||
"http://openapi.baidu.com/oauth/2.0/token?grant_type=authorization_code&code=#{code}&client_id=#{client_id}&client_secret=#{client_secret}&redirect_uri=oob"
|
||||
end
|
||||
|
||||
def get_access_token(code)
|
||||
uri = URI.parse(oauth_url(code))
|
||||
response = Net::HTTP.get_response(uri)
|
||||
Rails.logger.info "baidu_tongji_auth response.body ===== #{response.body}"
|
||||
if response.code.to_i == 200
|
||||
data = JSON.parse(response.body)
|
||||
access_token = data['access_token']
|
||||
refresh_token = data['refresh_token']
|
||||
expires_in = data['expires_in']
|
||||
if access_token.present?
|
||||
Rails.cache.write("baidu_tongji_auth/access_token", access_token, expires_in: expires_in)
|
||||
Rails.cache.write("baidu_tongji_auth/refresh_token", refresh_token, expires_in: 1.year)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def refresh_access_token
|
||||
url = "http://openapi.baidu.com/oauth/2.0/token?grant_type=refresh_token&refresh_token=#{refresh_token}&client_id=#{client_id}&client_secret=#{client_secret}"
|
||||
uri = URI.parse(url)
|
||||
response = Net::HTTP.get_response(uri)
|
||||
Rails.logger.info "baidu_tongji_auth response.body ===== #{response.body}"
|
||||
if response.code.to_i == 200
|
||||
data = JSON.parse(response.body)
|
||||
access_token = data['access_token']
|
||||
refresh_token = data['refresh_token']
|
||||
expires_in = data['expires_in']
|
||||
if access_token.present?
|
||||
Rails.cache.write("baidu_tongji_auth/access_token", access_token, expires_in: expires_in)
|
||||
Rails.cache.write("baidu_tongji_auth/refresh_token", refresh_token, expires_in: 1.year)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def access_token
|
||||
access_token = Rails.cache.read("baidu_tongji_auth/access_token")
|
||||
if access_token.blank? && refresh_token.present?
|
||||
refresh_access_token
|
||||
access_token = Rails.cache.read("baidu_tongji_auth/access_token")
|
||||
end
|
||||
access_token
|
||||
end
|
||||
|
||||
def refresh_token
|
||||
refresh_token = Rails.cache.read("baidu_tongji_auth/refresh_token")
|
||||
# 如果刷新token失效,access_token也重置
|
||||
if refresh_token.blank?
|
||||
Rails.cache.delete("baidu_tongji_auth/access_token")
|
||||
end
|
||||
refresh_token
|
||||
end
|
||||
|
||||
# 网站概况(趋势数据)
|
||||
def api_overview
|
||||
start_date = Time.now.beginning_of_week
|
||||
end_date = Time.now
|
||||
start_date = Time.now - 1.days if start_date.strftime("%Y%m%d") == end_date.strftime("%Y%m%d")
|
||||
api("overview/getTimeTrendRpt", start_date, end_date, "pv_count,visitor_count,ip_count")
|
||||
end
|
||||
|
||||
# 网站概况(来源网站、搜索词、入口页面、受访页面)
|
||||
def api_overview_getCommonTrackRpt
|
||||
start_date = Time.now.beginning_of_week
|
||||
end_date = Time.now
|
||||
api("overview/getCommonTrackRpt", start_date, end_date, "pv_count")
|
||||
end
|
||||
|
||||
# 全部来源
|
||||
def source_from
|
||||
start_date = Time.now.beginning_of_week
|
||||
end_date = Time.now
|
||||
api("source/all/a", start_date, end_date, "pv_count,visitor_count,ip_count")
|
||||
end
|
||||
|
||||
def api(api_method, start_date, end_date, metrics = nil)
|
||||
start_date_fmt = start_date.strftime("%Y%m%d")
|
||||
end_date_fmt = end_date.strftime("%Y%m%d")
|
||||
api_url = "https://openapi.baidu.com/rest/2.0/tongji/report/getData?access_token=#{access_token}&site_id=#{site_id}&method=#{api_method}&start_date=#{start_date_fmt}&end_date=#{end_date_fmt}&metrics=#{metrics}"
|
||||
data = url_http_post(api_url, {})
|
||||
data['result']
|
||||
end
|
||||
|
||||
def url_http_post(api_url, params)
|
||||
Rails.logger.info "api_url==#{api_url}"
|
||||
uri = URI.parse(api_url)
|
||||
http = Net::HTTP.new uri.host, uri.port
|
||||
http.open_timeout = 60
|
||||
http.read_timeout = 60
|
||||
if uri.scheme == 'https'
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
http.use_ssl = true
|
||||
end
|
||||
begin
|
||||
request = Net::HTTP::Post.new(uri)
|
||||
request.set_form_data(params) if params.present?
|
||||
request['Content-Type'] = 'application/json;charset=utf-8'
|
||||
# request['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'
|
||||
response = http.start { |http| http.request(request) }
|
||||
Rails.logger.info "api response.body==#{response.body}"
|
||||
JSON.parse response.body
|
||||
rescue => err
|
||||
Rails.logger.error("#############api_url:#{api_url},error:#{err.message.size}")
|
||||
# Rails.logger.error("#############api_url:#{api_url},error:#{err.message}")
|
||||
return {}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
16
app/services/cache/v2/project_common_service.rb
vendored
16
app/services/cache/v2/project_common_service.rb
vendored
@@ -1,5 +1,5 @@
|
||||
class Cache::V2::ProjectCommonService < ApplicationService
|
||||
attr_reader :project_id, :owner_id, :name, :identifier, :description, :visits, :watchers, :praises, :forks, :issues, :pullrequests, :commits
|
||||
attr_reader :project_id, :owner_id, :name, :identifier, :description, :visits, :watchers, :praises, :forks, :issues, :closed_issues, :pullrequests, :commits
|
||||
attr_accessor :project
|
||||
|
||||
def initialize(project_id, params={})
|
||||
@@ -13,6 +13,7 @@ class Cache::V2::ProjectCommonService < ApplicationService
|
||||
@praises = params[:praises]
|
||||
@forks = params[:forks]
|
||||
@issues = params[:issues]
|
||||
@closed_issues = params[:closed_issues]
|
||||
@pullrequests = params[:pullrequests]
|
||||
@commits = params[:commits]
|
||||
end
|
||||
@@ -78,6 +79,10 @@ class Cache::V2::ProjectCommonService < ApplicationService
|
||||
"issues"
|
||||
end
|
||||
|
||||
def closed_issues_key
|
||||
"closed_issues"
|
||||
end
|
||||
|
||||
def pullrequests_key
|
||||
"pullrequests"
|
||||
end
|
||||
@@ -151,6 +156,10 @@ class Cache::V2::ProjectCommonService < ApplicationService
|
||||
Cache::V2::ProjectRankService.call(@project_id, {issues: @issues})
|
||||
Cache::V2::ProjectDateRankService.call(@project_id, Date.today, {issues: @issues})
|
||||
end
|
||||
if @closed_issues.present?
|
||||
$redis_cache.hincrby(project_common_key, closed_issues_key, @closed_issues)
|
||||
Cache::V2::ProjectDateRankService.call(@project_id, Date.today, {closed_issues: @closed_issues})
|
||||
end
|
||||
if @pullrequests.present?
|
||||
$redis_cache.hincrby(project_common_key, pullrequests_key, @pullrequests)
|
||||
Cache::V2::ProjectRankService.call(@project_id, {pullrequests: @pullrequests})
|
||||
@@ -202,6 +211,10 @@ class Cache::V2::ProjectCommonService < ApplicationService
|
||||
$redis_cache.hset(project_common_key, issues_key, Issue.issue_issue.where(project_id: @project_id).count)
|
||||
end
|
||||
|
||||
def reset_project_closed_issues
|
||||
$redis_cache.hset(project_common_key, closed_issues_key, Issue.issue_issue.closed.where(project_id: @project_id).count)
|
||||
end
|
||||
|
||||
def reset_project_pullrequests
|
||||
$redis_cache.hset(project_common_key, pullrequests_key, PullRequest.where(project_id: @project_id).count)
|
||||
end
|
||||
@@ -224,6 +237,7 @@ class Cache::V2::ProjectCommonService < ApplicationService
|
||||
reset_project_praises
|
||||
reset_project_forks
|
||||
reset_project_issues
|
||||
reset_project_closed_issues
|
||||
reset_project_pullrequests
|
||||
reset_project_commits
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 项目日活跃度计算存储
|
||||
class Cache::V2::ProjectDateRankService < ApplicationService
|
||||
attr_reader :project_id, :rank_date, :visits, :praises, :forks, :issues, :pullrequests, :commits
|
||||
attr_reader :project_id, :rank_date, :visits, :praises, :forks, :issues, :closed_issues, :pullrequests, :commits
|
||||
attr_accessor :project_common
|
||||
|
||||
def initialize(project_id, rank_date=Date.today, params={})
|
||||
@@ -11,6 +11,7 @@ class Cache::V2::ProjectDateRankService < ApplicationService
|
||||
@praises = params[:praises]
|
||||
@forks = params[:forks]
|
||||
@issues = params[:issues]
|
||||
@closed_issues = params[:closed_issues]
|
||||
@pullrequests = params[:pullrequests]
|
||||
@commits = params[:commits]
|
||||
end
|
||||
@@ -57,6 +58,9 @@ class Cache::V2::ProjectDateRankService < ApplicationService
|
||||
$redis_cache.zincrby(project_rank_key, @issues.to_i * 5, @project_id)
|
||||
$redis_cache.hincrby(project_rank_statistic_key, "issues", @issues.to_i)
|
||||
end
|
||||
if @closed_issues.present?
|
||||
$redis_cache.hincrby(project_rank_statistic_key, "closed_issues", @closed_issues.to_i)
|
||||
end
|
||||
if @pullrequests.present?
|
||||
$redis_cache.zincrby(project_rank_key, @pullrequests.to_i * 10, @project_id)
|
||||
$redis_cache.hincrby(project_rank_statistic_key, "pullrequests", @pullrequests.to_i)
|
||||
|
||||
@@ -16,6 +16,6 @@ class Getway::Cms::GetService < Getway::ClientService
|
||||
end
|
||||
|
||||
def url
|
||||
"/cms/doc/open/#{doc_id}".freeze
|
||||
"/cms/doc/open/baseInfo/#{doc_id}".freeze
|
||||
end
|
||||
end
|
||||
@@ -29,7 +29,7 @@ class Gitea::User::GenerateTokenService < Gitea::ClientService
|
||||
end
|
||||
|
||||
def request_params
|
||||
{ name: "#{@username}-#{token_name}" }
|
||||
{ name: "#{@username}-#{token_name}", scopes: ["all"] }
|
||||
end
|
||||
|
||||
def token_name
|
||||
|
||||
@@ -26,7 +26,7 @@ class PageService
|
||||
Rails.logger.info "################### PageService close_site #{user_id} / #{identifier}"
|
||||
user = User.find user_id
|
||||
uri = if identifier.present?
|
||||
URI.parse("http://gitlink.#{@deploy_domain}/gitlink_execute_script?key=#{@deploy_key}&script_path=remove_dir&owner=#{user.login.downcase}/#{identifier}/")
|
||||
URI.parse("http://gitlink.#{@deploy_domain}/gitlink_execute_script?key=#{@deploy_key}&script_path=remove_dir&owner=#{user.login.downcase}/*")
|
||||
else
|
||||
URI.parse("http://gitlink.#{@deploy_domain}/gitlink_execute_script?key=#{@deploy_key}&script_path=remove_dir&owner=#{user.login.downcase}/")
|
||||
end
|
||||
|
||||
@@ -65,7 +65,8 @@ class Projects::CreateService < ApplicationService
|
||||
{
|
||||
hidden: !repo_is_public,
|
||||
user_id: params[:user_id],
|
||||
identifier: params[:repository_name]
|
||||
identifier: params[:repository_name],
|
||||
auto_init: params[:auto_init]
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class Repositories::CreateService < ApplicationService
|
||||
end
|
||||
|
||||
def repository_params
|
||||
params.merge(project_id: project.id)
|
||||
params.merge(project_id: project.id).except(:auto_init)
|
||||
end
|
||||
|
||||
def gitea_repository_params
|
||||
@@ -75,7 +75,7 @@ class Repositories::CreateService < ApplicationService
|
||||
name: params[:identifier],
|
||||
private: params[:hidden],
|
||||
# readme: "ReadMe",
|
||||
"auto_init": true,
|
||||
auto_init: params[:auto_init],
|
||||
# "description": "string",
|
||||
# "gitignores": "string",
|
||||
# "issue_labels": "string",
|
||||
@@ -89,7 +89,7 @@ class Repositories::CreateService < ApplicationService
|
||||
license = project.license
|
||||
hash = hash.merge(license: license.name) if license
|
||||
hash = hash.merge(gitignores: ignore.name) if ignore
|
||||
hash = hash.merge(auto_init: true) if ignore || license
|
||||
hash = hash.merge(auto_init: true) if ignore && license
|
||||
hash
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user