Merge branch 'standalone_develop' into pre_trustie_server
This commit is contained in:
commit
d42acc9aa9
|
@ -15,6 +15,7 @@ class CommitLogsController < ApplicationController
|
|||
owner = User.find_by(login: owner_name)
|
||||
project = Project.where(identifier: repository_name).where(user_id: owner&.id)&.first
|
||||
project = Project.where(identifier: repository_name).where(gpid: repository_id)&.first if project.blank?
|
||||
project.update_column(:updated_on, Time.now) if project.present?
|
||||
params[:commits].each do |commit|
|
||||
commit_id = commit[:id]
|
||||
message = commit[:message]
|
||||
|
|
|
@ -34,7 +34,7 @@ class ObRepositorySyncsController < ApplicationController
|
|||
def delete
|
||||
service = ObRepositorySync::ApiService.new(@ob_repository_sync.name)
|
||||
res = service.delete_project @ob_repository_sync.sync_id
|
||||
tip_exception "保存失败: #{res["msg"]}" if res["code"].to_s != "200"
|
||||
tip_exception "删除失败: #{res["msg"]}" if res["code"].to_s != "200"
|
||||
if res["code"].to_s == "200"
|
||||
@ob_repository_sync.destroy!
|
||||
end
|
||||
|
@ -43,14 +43,17 @@ class ObRepositorySyncsController < ApplicationController
|
|||
|
||||
def jobs
|
||||
tip_exception "该项目未创建同步任务" if @ob_repository_sync.blank?
|
||||
page = params[:page] || 1
|
||||
limit = params[:limit] || 10
|
||||
service = ObRepositorySync::ApiService.new(@ob_repository_sync.name)
|
||||
res = service.get_projects_jobs
|
||||
data = res["data"]["list"]
|
||||
source = ""
|
||||
if params[:type] && params[:type].to_s.downcase == "github"
|
||||
data = data.select { |row| row["github_branch"].present? }
|
||||
source = "github_branch"
|
||||
elsif params[:type] && params[:type].to_s.downcase == "gitee"
|
||||
data = data.select { |row| row["gitee_branch"].present? }
|
||||
source = "gitee_branch"
|
||||
end
|
||||
res = service.get_projects_jobs(source, page, limit)
|
||||
data = res["data"]["list"]
|
||||
render_ok(count: res["data"]["total"], data: data)
|
||||
end
|
||||
|
||||
|
@ -83,7 +86,7 @@ class ObRepositorySyncsController < ApplicationController
|
|||
tip_exception "缺少参数job_id" if params[:job_id].blank?
|
||||
service = ObRepositorySync::ApiService.new(@ob_repository_sync.name)
|
||||
res = service.delete_job params[:job_id]
|
||||
tip_exception "保存失败: #{res["msg"]}" if res["code"].to_s != "200"
|
||||
tip_exception "删除失败: #{res["msg"]}" if res["code"].to_s != "200"
|
||||
job = ObRepositorySyncJob.find_by(ob_repository_sync_id: @ob_repository_sync.id, job_id: params[:job_id])
|
||||
job.destroy! if job.present?
|
||||
render_ok
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class Traces::BaseController < ApplicationController
|
||||
|
||||
helper_method :observed_logged_user?, :observed_user
|
||||
|
||||
before_action :check_trace_system
|
||||
|
||||
def observed_user
|
||||
@_observed_user ||= (User.find_by_login(params[:user_id]) || User.find_by_id(params[:user_id]))
|
||||
|
@ -15,4 +15,12 @@ class Traces::BaseController < ApplicationController
|
|||
def check_auth
|
||||
return render_forbidden unless current_user.admin? || observed_logged_user?
|
||||
end
|
||||
|
||||
def check_trace_system
|
||||
code, data, error = Trace::SystemInfoService.call(current_user.trace_token)
|
||||
return render_ok({code: 501, data: {operate_time: data['operate_time']}, message: '系统维护中'}) if data['status'] === 0
|
||||
rescue
|
||||
# 这里根据需求跳转到404
|
||||
return render_not_found
|
||||
end
|
||||
end
|
|
@ -95,21 +95,31 @@ module ApplicationHelper
|
|||
timePassed = currentTime - lastUpdateTime
|
||||
timeIntoFormat = 0
|
||||
updateAtValue = ""
|
||||
if timePassed < 0
|
||||
|
||||
if timePassed <= 0
|
||||
updateAtValue = "刚刚"
|
||||
elsif timePassed < 2 * 1000
|
||||
updateAtValue = "1秒前"
|
||||
elsif timePassed < ONE_MINUTE
|
||||
updateAtValue = "1分钟前"
|
||||
elsif timePassed < ONE_HOUR
|
||||
timeIntoFormat = timePassed / ONE_MINUTE
|
||||
updateAtValue = timeIntoFormat.to_s + "分钟前"
|
||||
elsif (timePassed < ONE_DAY)
|
||||
timeIntoFormat = (timePassed.to_f / ONE_HOUR).ceil
|
||||
timeIntoFormat = (timePassed.to_f / ONE_HOUR).round
|
||||
timeIntoFormat == 1 if timeIntoFormat.to_i == 0
|
||||
updateAtValue = timeIntoFormat.to_s + "小时前"
|
||||
elsif (timePassed < ONE_MONTH)
|
||||
timeIntoFormat = (timePassed.to_f / ONE_DAY).ceil
|
||||
timeIntoFormat = (timePassed.to_f / ONE_DAY).round
|
||||
timeIntoFormat == 1 if timeIntoFormat.to_i == 0
|
||||
updateAtValue = timeIntoFormat.to_s + "天前"
|
||||
elsif (timePassed < ONE_MONTH)
|
||||
timeIntoFormat = (timePassed.to_f / ONE_DAY).round
|
||||
timeIntoFormat == 1 if timeIntoFormat.to_i == 0
|
||||
updateAtValue = timeIntoFormat.to_s + "天前"
|
||||
elsif (timePassed < ONE_YEAR)
|
||||
timeIntoFormat = (timePassed.to_f / ONE_MONTH).ceil
|
||||
timeIntoFormat = (timePassed.to_f / ONE_MONTH).round
|
||||
timeIntoFormat == 1 if timeIntoFormat.to_i == 0
|
||||
updateAtValue = timeIntoFormat.to_s + "个月前"
|
||||
else
|
||||
timeIntoFormat = timePassed / ONE_YEAR
|
||||
|
|
|
@ -64,6 +64,7 @@ module ProjectsHelper
|
|||
project_language_id: project.project_language_id,
|
||||
license_id: project.license_id,
|
||||
jianmu_devops: jianmu_devops_code(project, user),
|
||||
jianmu_devops_url: jianmu_devops_url,
|
||||
ignore_id: project.ignore_id
|
||||
}).compact
|
||||
|
||||
|
@ -123,6 +124,10 @@ module ProjectsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def jianmu_devops_url
|
||||
EduSetting.get("jianmu_devops_url") || "https://ci-v3.test.jianmuhub.com"
|
||||
end
|
||||
|
||||
def aes_encrypt(key, des_text)
|
||||
# des_text='{"access_key_id":"STS.NTuC9RVmWfJqj3JkcMzPnDf7X","access_key_secret":"E8NxRZWGNxxMfwgt5nFLnBFgg6AzgXCZkSNCyqygLuHM","end_point":"oss-accelerate.aliyuncs.com","security_token":"CAIS8gF1q6Ft5B2yfSjIr5fACIPmu7J20YiaaBX7j2MYdt9Cq6Ocujz2IHhMenVhA+8Wv/02n2hR7PcYlq9IS55VWEqc/VXLaywQo22beIPkl5Gfz95t0e+IewW6Dxr8w7WhAYHQR8/cffGAck3NkjQJr5LxaTSlWS7OU/TL8+kFCO4aRQ6ldzFLKc5LLw950q8gOGDWKOymP2yB4AOSLjIx6lAt2T8vs/7hmZPFukSFtjCglL9J/baWC4O/csxhMK14V9qIx+FsfsLDqnUIs0YWpf0p3P0doGyf54vMWUM05A6dduPS7txkLAJwerjVl1/ADxc0/hqAASXhPeiktbmDjwvnSn4iKcSGQ+xoQB468eHXNdvf13dUlbbE1+JhRi0pZIB2UCtN9oTsLHcwIHt+EJaoMd3+hGwPVmvHSXzECDFHylZ8l/pzTwlE/aCtZyVmI5cZEvmWu2xBa3GRbULo7lLvyeX1cHTVmVWf4Nk6D09PzTU8qlAj","bucket":"edu-bigfiles1","region":"oss-cn-hangzhou","callback_url":"https://data.educoder.net/api/buckets/callback.json","bucket_host":"data.educoder.net"}'
|
||||
# des = OpenSSL::Cipher::Cipher.new('aes-256-ctr')
|
||||
|
|
|
@ -32,7 +32,8 @@ class VersionRelease < ApplicationRecord
|
|||
has_many :attachments, as: :container, dependent: :destroy
|
||||
|
||||
def update_sha
|
||||
return if version_gid.blank?
|
||||
git_release = Gitea::Versions::GetService.call(user.gitea_token, repository&.owner&.login, repository&.identifier, version_gid)
|
||||
self.update(sha: git_release["sha"])
|
||||
self.update(sha: git_release["sha"]) if git_release.present? && git_release.is_a?(Hash)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,8 +42,8 @@ class ObRepositorySync::ApiService < ApplicationService
|
|||
res
|
||||
end
|
||||
|
||||
def get_projects_jobs
|
||||
url = URI("#{domain}/cerobot/projects/#{@project_name}/jobs?pageSize=100&pageNum=1")
|
||||
def get_projects_jobs(source, pageNum = 1, pageSize = 100)
|
||||
url = URI("#{domain}/cerobot/projects/#{@project_name}/jobs?pageSize=#{pageSize}&pageNum=#{pageNum}&source=#{source}")
|
||||
http = Net::HTTP.new(url.host, url.port)
|
||||
request = Net::HTTP::Get.new(url)
|
||||
request["Content-Type"] = "application/json"
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
class Trace::SystemInfoService < Trace::ClientService
|
||||
|
||||
attr_accessor :token
|
||||
|
||||
def initialize(token)
|
||||
@token = token
|
||||
end
|
||||
|
||||
def call
|
||||
result = authed_get(token, url)
|
||||
response = render_response(result)
|
||||
end
|
||||
|
||||
private
|
||||
def url
|
||||
'/user/systemInfo'.freeze
|
||||
end
|
||||
end
|
|
@ -6,6 +6,7 @@ json.status message["status"]
|
|||
json.content message["content"]
|
||||
json.notification_url message["notification_url"]
|
||||
json.source message["source"]
|
||||
json.created_at message["created_at"]
|
||||
json.time_ago time_from_now(message["created_at"].to_time)
|
||||
|
||||
case message["type"]
|
||||
|
|
Loading…
Reference in New Issue