Compare commits

..

No commits in common. "master" and "feature_commit_speed" have entirely different histories.

149 changed files with 871 additions and 99694 deletions

View File

@ -1,17 +1,13 @@
FROM ubuntu:20.04
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata
# basics
RUN apt-get install -y libssl-dev curl libmysqlclient-dev imagemagick nodejs mysql-server redis-server
RUN apt-get install -y libssl-dev curl libmysqlclient-dev imagemagick nodejs mysql-server redis-server tzdata
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# confirm openssl version
RUN openssl version
RUN which openssl
# install RVM, Ruby, and Bundler
RUN \curl -L https://get.rvm.io | bash -s stable
# rvm environment variable
RUN /bin/bash -l -c "source /etc/profile.d/rvm.sh"
RUN /bin/bash -l -c "rvm requirements"
# replace ruby mirror url, accelerate install ruby
RUN sed -i 's/rvm_remote_server_url2/#rvm_remote_server_url2/g' /usr/local/rvm/config/db
@ -41,19 +37,11 @@ RUN /bin/bash -l -c 'gem install puma -v 5.6.5'
RUN rm -rf Gemfile.lock
RUN cp config/configuration.yml.example config/configuration.yml
RUN cp config/database-docker.yml.example config/database.yml
RUN cp config/database.yml.example config/database.yml
RUN touch config/redis.yml
RUN touch config/elasticsearch.yml
RUN /bin/bash -l -c 'bundle install'
RUN redis-server &
RUN /bin/bash -l -c 'bundle exec rake sync_table_structure:import_csv'
RUN /bin/bash -l -c 'rails db:migrate RAILS_ENV=development'
RUN /bin/bash -l -c 'bundle exec sidekiq -C config/sidekiq.yml -e production -d'
EXPOSE 4000
RUN /bin/bash -l -c 'RAILS_ENV=production puma -C config/puma.rb'
#EXPOSE 4000
#RUN /bin/bash -l -c 'RAILS_ENV=production puma'

View File

@ -1,19 +0,0 @@
FROM ubuntu:20.04
RUN apt-get update
# basics
RUN apt-get install -y libssl-dev curl libmysqlclient-dev imagemagick nodejs mysql-server redis-server tzdata
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# confirm openssl version
RUN openssl version
RUN which openssl
# install RVM, Ruby, and Bundler
RUN \curl -L https://get.rvm.io | bash -s stable
RUN /bin/bash -l -c "rvm requirements"
# replace ruby mirror url, accelerate install ruby
RUN sed -i 's/rvm_remote_server_url2/#rvm_remote_server_url2/g' /usr/local/rvm/config/db
RUN sed -i 's/cache.ruby-lang.org/cache.ruby-china.com/g' /usr/local/rvm/config/db
# install ruby
RUN /bin/bash -l -c "rvm install 2.4.5"
# confirm ruby version
RUN /bin/bash -l -c "rvm list"
RUN /bin/bash -l -c "ruby -v"

View File

@ -1,3 +1,11 @@
GIT
remote: https://gitlink.org.cn/KingChan/sonarqube.git
revision: 80f07d427322ef02c0714c77a382e87aed0bef81
specs:
sonarqube (1.3.0)
httparty (~> 0.14, >= 0.14.0)
terminal-table (~> 1.5, >= 1.5.1)
GEM
remote: https://mirrors.cloud.tencent.com/rubygems/
specs:
@ -99,7 +107,6 @@ GEM
archive-zip (~> 0.10)
nokogiri (~> 1.8)
chunky_png (1.3.11)
coderay (1.1.3)
concurrent-ruby (1.1.6)
connection_pool (2.2.2)
crass (1.0.6)
@ -136,7 +143,7 @@ GEM
fugit (1.4.1)
et-orbi (~> 1.1, >= 1.1.8)
raabro (~> 1.4)
gitea-client (1.5.9)
gitea-client (1.4.6)
rest-client (~> 2.1.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
@ -149,8 +156,11 @@ GEM
hashie (3.6.0)
htmlentities (4.3.4)
http-accept (1.7.0)
http-cookie (1.0.8)
http-cookie (1.0.5)
domain_name (~> 0.5)
httparty (0.21.0)
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
io-like (0.3.1)
@ -179,8 +189,7 @@ GEM
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
logger (1.6.6)
loofah (2.20.0)
loofah (2.4.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
@ -189,10 +198,9 @@ GEM
mimemagic (~> 0.3.2)
maruku (0.7.3)
method_source (0.9.2)
mime-types (3.6.0)
logger
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2025.0220)
mime-types-data (3.2024.0507)
mimemagic (0.3.10)
nokogiri (~> 1)
rake
@ -247,13 +255,8 @@ GEM
popper_js (1.16.0)
powerpack (0.1.2)
prettier (0.18.2)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
pry-rails (0.3.9)
pry (>= 0.10.4)
public_suffix (4.0.3)
puma (5.6.5)
puma (5.6.8)
nio4r (~> 2.0)
raabro (1.4.0)
rack (2.0.9)
@ -445,6 +448,8 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
@ -455,7 +460,9 @@ GEM
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unf (0.2.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.9.1)
unicode-display_width (1.6.1)
web-console (3.7.0)
actionview (>= 5.0)
@ -497,7 +504,7 @@ DEPENDENCIES
enumerize
faraday (~> 0.15.4)
font-awesome-sass (= 4.7.0)
gitea-client (~> 1.5.8)
gitea-client (~> 1.4.3)
grape-entity (~> 0.7.1)
groupdate (~> 4.1.0)
harmonious_dictionary (~> 0.0.1)
@ -507,7 +514,6 @@ DEPENDENCIES
kaminari (~> 1.1, >= 1.1.1)
letter_avatar
listen (>= 3.0.5, < 3.2)
loofah (~> 2.20.0)
mysql2 (>= 0.4.4, < 0.6.0)
oauth2
omniauth (~> 1.9.0)
@ -520,7 +526,6 @@ DEPENDENCIES
parallel (~> 1.19, >= 1.19.1)
pdfkit
prettier
pry-rails
puma (~> 5.6.5)
rack-cors
rails (~> 5.2.0)
@ -547,6 +552,7 @@ DEPENDENCIES
simple_xlsx_reader (~> 1.0.4)
sinatra
solargraph (~> 0.38.0)
sonarqube!
spreadsheet
spring
spring-watcher-listen (~> 2.0.0)

View File

@ -1,10 +1,9 @@
# GitLink - CCF开源创新服务平台
# GitLink - CCF开源创新服务平台
GitLink确实开源是中国计算机学会CCF官方指定的开源创新服务平台旨在以“为开源创新服务”为使命以“成为开源创新的汇聚地”为愿景秉承“创新、开放、协作、共享”的价值观致力于为大规模开源开放协同创新助力赋能打造创新成果孵化和新工科人才培养的开源创新生态
<center>
<img src="docs/figs/gitlink.png" width=80% /></center>
<img src="https://code.gitlink.org.cn/young/forgeplus/raw/branch/master/docs/figs/gitlink.png?raw=true" width=80% /></center>
## 特色功能
@ -175,31 +174,31 @@ http://localhost:3000/
- 项目列表
<center>
<img src="docs/figs/project_list.png" width=80% />
<img src="https://code.gitlink.org.cn/young/forgeplus/raw/branch/master/docs/figs/project_list.png?raw=true" width=50% />
</center>
- 代码仓库
<center>
<img src="docs/figs/repo.png" width=80% />
<img src="https://code.gitlink.org.cn/young/forgeplus/raw/branch/master/docs/figs/repo.png?raw=true" width=50% />
</center>
- 任务管理
<center>
<img src="docs/figs/issues.png" width=80% />
<img src="https://code.gitlink.org.cn/young/forgeplus/raw/branch/master/docs/figs/issues.png?raw=true" width=50% />
</center>
- 合并请求
<center>
<img src="docs/figs/PR.png" width=80% />
<img src="https://code.gitlink.org.cn/young/forgeplus/raw/branch/master/docs/figs/PR.png?raw=true" width=50% />
</center>
- 引擎配置
<center>
<img src="docs/figs/engine.png" width=80% />
<img src="https://code.gitlink.org.cn/young/forgeplus/raw/branch/master/docs/figs/engine.png?raw=true" width=50% />
</center>

View File

@ -1,7 +1,6 @@
class AccountsController < ApplicationController
before_action :require_login, only: [:login_check, :simple_update, :change_password]
include ApplicationHelper
include AesCryptHelper
#skip_before_action :check_account, :only => [:logout]
@ -32,12 +31,11 @@ class AccountsController < ApplicationController
username = params[:username]&.gsub(/\s+/, "")
tip_exception("无法使用以下关键词:#{username},请重新命名") if ReversedKeyword.check_exists?(username)
email = params[:email]&.gsub(/\s+/, "")
phone = params[:phone]&.gsub(/\s+/, "")
password = params[:password]
platform = (params[:platform] || 'forge')&.gsub(/\s+/, "")
ActiveRecord::Base.transaction do
result = autologin_register(username, email, password, platform, phone)
result = autologin_register(username, email, password, platform)
if result[:message].blank?
render_ok({user: result[:user]})
else
@ -145,8 +143,7 @@ class AccountsController < ApplicationController
user = Users::RegisterService.call(register_params)
user.mail = "#{user.login}@example.org" if user.mail.blank?
password = decrypt(register_params[:password]) rescue register_params[:password].to_s
password = password.strip
password = register_params[:password].strip
# gitea用户注册, email, username, password
interactor = Gitea::RegisterInteractor.call({username: user.login, email: user.mail, password: password})
@ -196,9 +193,8 @@ class AccountsController < ApplicationController
# 用户登录
def login
password = decrypt(login_params[:password]) rescue login_params[:password].to_s
Users::LoginForm.new(login_params.merge!({password: password})).validate!
@user = User.try_to_login(params[:login], password)
Users::LoginForm.new(login_params).validate!
@user = User.try_to_login(params[:login], params[:password])
return normal_status(-2, "错误的账号或密码") if @user.blank?
# user is already in local database
@ -207,7 +203,7 @@ class AccountsController < ApplicationController
login_control = LimitForbidControl::UserLogin.new(@user)
return normal_status(-2, "登录密码出错已达上限,账号已被锁定,请#{login_control.forbid_expires/60}分钟后重新登录或找回密码") if login_control.forbid?
password_ok = @user.check_password?(password.to_s)
password_ok = @user.check_password?(params[:password].to_s)
unless password_ok
if login_control.remain_times-1 == 0
normal_status(-2, "登录密码出错已达上限,账号已被锁定,请#{login_control.forbid_expires/60}分钟后重新登录或找回密码")
@ -220,24 +216,21 @@ class AccountsController < ApplicationController
LimitForbidControl::UserLogin.new(@user).clear
successful_authentication(@user)
sync_pwd_to_gitea!(@user, {password: password.to_s}) # TODO用户密码未同步
sync_pwd_to_gitea!(@user, {password: params[:password].to_s}) # TODO用户密码未同步
# session[:user_id] = @user.id
end
def change_password
password = decrypt(params[:password]) rescue params[:password].to_s
new_password_repeat = decrypt(params[:new_password_repeat]) rescue params[:new_password_repeat].to_s
old_password = decrypt(params[:old_password]) rescue params[:old_password]
return render_error("两次输入的密码不一致") if password.to_s != new_password_repeat.to_s
return render_error("两次输入的密码不一致") if params[:password].to_s != params[:new_password_repeat].to_s
@user = User.find_by(login: params[:login])
return render_forbidden unless User.current.login == @user&.login
return render_error("此用户禁止修改密码!") if @user.id.to_i === 104691
return render_error("未找到相关用户!") if @user.blank?
return render_error("旧密码不正确") unless @user.check_password?(old_password)
return render_error("旧密码不正确") unless @user.check_password?(params[:old_password])
sync_params = {
password: password.to_s,
password: params[:password].to_s,
email: @user.mail,
login_name: @user.name,
source_id: 0
@ -245,7 +238,7 @@ class AccountsController < ApplicationController
interactor = Gitea::User::UpdateInteractor.call(@user.login, sync_params)
if interactor.success?
@user.update_attribute(:password, password)
@user.update_attribute(:password, params[:password])
render_ok
else
render_error(interactor.error)

View File

@ -6,7 +6,7 @@ class Action::NodeInputsController < ApplicationController
@node_inputs = @node.action_node_inputs
respond_to do |format|
format.html
format.json{ render_ok(data: @node_inputs.as_json) }
format.json
end
end
@ -67,9 +67,9 @@ class Action::NodeInputsController < ApplicationController
def node_input_params
if params.require(:action_node_input)
params.require(:action_node_input).permit(:name, :input_type, :description, :is_required, :sort_no, :default_value)
params.require(:action_node_input).permit(:name, :input_type, :description, :is_required, :sort_no)
else
params.permit(:name, :input_type, :description, :is_required, :sort_no, :default_value)
params.permit(:name, :input_type, :description, :is_required, :sort_no)
end
end
end

View File

@ -4,10 +4,6 @@ class Action::NodeTypesController < ApplicationController
def index
@node_types = Action::NodeType.all
respond_to do |format|
format.html
format.json { render_ok(data: @node_types.as_json) }
end
end
def create
@ -24,10 +20,7 @@ class Action::NodeTypesController < ApplicationController
end
def show
respond_to do |format|
format.html
format.json { render_ok(data: @node_type.as_json) }
end
end
def new
@ -52,10 +45,7 @@ class Action::NodeTypesController < ApplicationController
else
flash[:danger] = '删除失败'
end
respond_to do |format|
format.html { redirect_to action_node_types_path }
format.json { render_ok }
end
redirect_to action_node_types_path
end
private

View File

@ -1,25 +1,18 @@
class Action::NodesController < ApplicationController
# before_action :require_admin, except: [:index]
before_action :require_login
before_action :require_admin, except: [:index]
before_action :find_action_node, except: [:index, :create, :new]
def index
@node_types = Action::NodeType.all
no_node_type = Action::NodeType.find_by(name: "未分类")
@no_type_nodes = Action::Node.where(action_node_types_id: nil)
@no_type_nodes = Action::Node.where(action_node_types_id: nil).or(Action::Node.where(action_node_types_id: no_node_type.id)) if no_node_type.present?
respond_to do |format|
format.html { @nodes = Action::Node.where("name LIKE :search OR full_name LIKE :search", :search => "%#{params[:search]}%") }
format.html { @nodes = Action::Node.all }
format.json
end
end
def create
@node = Action::Node.new(node_params)
if params.require(:node).present? && params.require(:node)[:link_type_array].present?
@node.link_type = (params.require(:node)[:link_type_array] - [""]).join(",")
end
@node.user_id = current_user.id
respond_to do |format|
if @node.save
format.html { redirect_to action_nodes_path, notice: '创建成功.' }
@ -40,16 +33,10 @@ class Action::NodesController < ApplicationController
end
def edit
if @node.link_type.present?
@node.link_type_array = @node.link_type.to_s.split(",")
end
end
def update
if params.require(:node).present? && params.require(:node)[:link_type_array].present?
@node.link_type = (params.require(:node)[:link_type_array] - [""]).join(",")
end
@node.user_id = current_user.id if @node.user_id.blank?
@node.update(node_params)
respond_to do |format|
format.html { redirect_to action_nodes_path, notice: '更新成功.' }
@ -63,10 +50,7 @@ class Action::NodesController < ApplicationController
else
flash[:danger] = '删除失败'
end
respond_to do |format|
format.html { redirect_to action_nodes_path }
format.json { render_ok() }
end
redirect_to action_nodes_path
end
private
@ -77,11 +61,9 @@ class Action::NodesController < ApplicationController
def node_params
if params.require(:action_node)
params.require(:action_node).permit(:name, :label, :full_name, :description, :icon, :action_node_types_id,
:is_local, :local_url, :yaml, :sort_no, :node_type, :is_mutil_link, :link_type, :link_type_array)
params.require(:action_node).permit(:name, :label, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no)
else
params.permit(:name, :label, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url,
:yaml, :sort_no, :node_type, :is_mutil_link, :link_type, :link_type_array)
params.permit(:name, :label, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no)
end
end
end

View File

@ -49,10 +49,7 @@ class Action::TemplatesController < ApplicationController
else
flash[:danger] = '删除失败'
end
respond_to do |format|
format.html { redirect_to action_templates_path }
format.json { render_ok }
end
redirect_to action_templates_path
end
private

View File

@ -1,13 +1,9 @@
class Admins::DashboardsController < Admins::BaseController
def index
# 查询优化
week_greater_id = CommitLog.where(created_at: current_week).limit(1)[0]&.id
#月份统计还需要优化
month_greater_id = CommitLog.where(created_at: current_month).limit(1)[0]&.id
# 用户活跃数
day_user_ids = CommitLog.where(created_at: today).pluck(:user_id).uniq
weekly_user_ids = CommitLog.where(created_at: current_week).where("id>= ?", week_greater_id).distinct.pluck(:user_id)
month_user_ids = CommitLog.where(created_at: current_month).where("id>= ?", month_greater_id).distinct.pluck(:user_id)
weekly_user_ids = CommitLog.where(created_at: current_week).pluck(:user_id).uniq
month_user_ids = CommitLog.where(created_at: current_month).pluck(:user_id).uniq
@active_user_count = User.where(last_login_on: today).or(User.where(id: day_user_ids)).count
@weekly_active_user_count = User.where(last_login_on: current_week).or(User.where(id: weekly_user_ids)).count
@month_active_user_count = User.where(last_login_on: current_month).or(User.where(id: month_user_ids)).count
@ -22,8 +18,8 @@ class Admins::DashboardsController < Admins::BaseController
# 活跃项目数
day_project_ids = (CommitLog.where(created_at: today).pluck(:project_id).uniq + Issue.where(created_on: today).pluck(:project_id).uniq).uniq
weekly_project_ids = (CommitLog.where(created_at: current_week).where("id>= ?", week_greater_id).distinct.pluck(:project_id) + Issue.where(created_on: current_week).pluck(:project_id).uniq).uniq
month_project_ids = (CommitLog.where(created_at: current_month).where("id>= ?", month_greater_id).distinct.pluck(:project_id) + Issue.where(created_on: current_month).pluck(:project_id).uniq).uniq
weekly_project_ids = (CommitLog.where(created_at: current_week).pluck(:project_id).uniq + Issue.where(created_on: current_week).pluck(:project_id).uniq).uniq
month_project_ids = (CommitLog.where(created_at: current_month).pluck(:project_id).uniq + Issue.where(created_on: current_month).pluck(:project_id).uniq).uniq
@day_active_project_count = Project.where(updated_on: today).or(Project.where(id: day_project_ids)).count
@weekly_active_project_count = Rails.cache.fetch("dashboardscontroller:weekly_active_project_count", expires_in: 10.minutes) do
Project.where(updated_on: current_week).or(Project.where(id: weekly_project_ids)).count

View File

@ -2,7 +2,7 @@ class Admins::NpsController < Admins::BaseController
before_action :require_business
def index
@on_off_switch = EduSetting.get("nps-on-off-switch").to_s == 'true'
@user_nps = UserNp.order(created_at: :desc)
@user_nps = UserNp.joins(:user).order(created_at: :desc)
keyword = params[:keyword].to_s.strip.presence
if keyword
sql = 'CONCAT(users.lastname, users.firstname) LIKE :keyword OR users.nickname LIKE :keyword OR users.login LIKE :keyword OR users.mail LIKE :keyword OR users.phone LIKE :keyword'

View File

@ -37,22 +37,19 @@ class Admins::ProjectsRankController < Admins::BaseController
def export_excel(data)
book = Spreadsheet::Workbook.new
sheet = book.create_worksheet :name => "项目活跃度排行"
sheet.row(0).concat %w(排名 项目全称 项目地址 项目分类 首次创建时间 外部迁移/独立创建 得分 访问数 关注数 点赞数 fork数 疑修数 合并请求数 提交数)
sheet.row(0).concat %w(排名 项目全称 项目地址 得分 访问数 关注数 点赞数 fork数 疑修数 合并请求数 提交数)
data.each_with_index do |d, index|
sheet[index+1,0] = index+1
sheet[index+1,1] = "#{d&.project&.owner&.real_name}/#{d&.project&.name}"
sheet[index+1,2] = "#{Rails.application.config_for(:configuration)['platform_url']}/#{d&.project&.owner&.login}/#{d&.project&.identifier}"
sheet[index+1,3] = d&.project&.project_category&.name
sheet[index+1,4] = d&.project&.created_on.present? ? d&.project&.created_on.strftime("%Y-%m-%d %H:%M:%S") : ""
sheet[index+1,5] = d&.project&.common? ? "独立创建" : "外部迁移"
sheet[index+1,6] = d.score
sheet[index+1,7] = d.visits
sheet[index+1,8] = d.watchers
sheet[index+1,9] = d.praises
sheet[index+1,10] = d.forks
sheet[index+1,11] = d.issues
sheet[index+1,12] = d.pullrequests
sheet[index+1,13] = d.commits
sheet[index+1,3] = d.score
sheet[index+1,4] = d.visits
sheet[index+1,5] = d.watchers
sheet[index+1,6] = d.praises
sheet[index+1,7] = d.forks
sheet[index+1,8] = d.issues
sheet[index+1,9] = d.pullrequests
sheet[index+1,10] = d.commits
end
book.write "#{Rails.root}/public/项目活跃度排行.xls"
end

View File

@ -1,45 +0,0 @@
class Api::Pm::ActionRunsController < Api::Pm::BaseController
before_action :require_login
def index
tip_exception('请输入workflows') if params[:workflows].blank?
@owner = Owner.find_by(login: params[:owner_id].to_s) || Owner.find_by(id: params[:owner_id].to_s)
tip_exception('组织未找到') if @owner.blank?
action_runs = Gitea::ActionRun.where(owner_id: @owner.gitea_uid)
group_data = action_runs.where(workflow_id: params[:workflows].to_s.split(",")).where(status: [1,2]).group(:workflow_id, :status).count
@result = []
params[:workflows].to_s.split(",").each do |file|
last_action_run = action_runs.where(workflow_id: file).order(updated: :desc).first
last_action_run_json = last_action_run.present? ? {
id: last_action_run.id,
schedule: last_action_run.schedule_id > 0,
title: last_action_run.title,
index: last_action_run.index,
status: last_action_run.status,
started: last_action_run.started,
stopped: last_action_run.stopped,
length: last_action_run.stopped - last_action_run.started,
created: last_action_run.created,
updated: last_action_run.updated,
} : {}
total = 0
success = 0
failure = 0
group_data.each do |k,v|
total += v if k[0] == file
success += v if k[0] == file && k[1] == 1
failure += v if k[0] == file && k[1] == 2
end
@result << {
name: file,
total: total,
success: success,
failure: failure
}.merge(last_action_run_json)
end
render :json => {data: @result}
end
end

View File

@ -30,8 +30,8 @@ class Api::Pm::BaseController < ApplicationController
end
def load_issue
# return render_parameter_missing if params[:pm_project_id].blank?
@issue = Issue.issue_issue.find_by_id(params[:issue_id])
return render_parameter_missing if params[:pm_project_id].blank?
@issue = Issue.issue_issue.where(pm_project_id: params[:pm_project_id]).find_by_id(params[:issue_id])
render_not_found('疑修不存在!') if @issue.blank?
end
# 具有对仓库的管理权限

View File

@ -1,138 +0,0 @@
class Api::Pm::DashboardsController < Api::Pm::BaseController
before_action :require_login
def index
end
def todo
return render_error('请输入正确的pm_project_ids.') if params[:pm_project_ids].blank?
pm_project_ids = params[:pm_project_ids].split(",") rescue []
date = params[:date].present? ? params[:date].to_date : Date.today rescue Date.today
@issues = Issue.where("start_date <= ? and due_date >= ?", date, date)
@issues = @issues.where(pm_project_id: pm_project_ids).joins(:issue_participants).where(issue_participants: {participant_id: current_user.id, participant_type: 'assigned'})
@issues = @issues.where.not(status_id: 5)
@issues = kaminari_paginate(@issues.distinct.pm_includes)
end
def my_issues
return render_error('请输入正确的pm_project_ids.') if params[:pm_project_ids].blank?
return render_error('请输入正确的pm_issue_types.') if params[:pm_issue_types].blank?
pm_project_ids = params[:pm_project_ids].split(",") rescue []
pm_issue_types = params[:pm_issue_types].split(",") rescue []
@all_issues = Issue.where(pm_project_id: pm_project_ids, pm_issue_type: pm_issue_types)
@issues = @all_issues.joins(:issue_participants).where(issue_participants: {participant_id: current_user.id, participant_type: 'assigned'})
@issues = @issues.where.not(status_id: 5) if params[:category] == "opened"
@issues = kaminari_paginate(@issues.distinct.pm_includes)
@my_assign_requirements_count = @all_issues.where(pm_issue_type: 1).joins(:issue_participants).where(issue_participants: {participant_id: current_user.id, participant_type: 'assigned'}).size
@my_assign_tasks_count = @all_issues.where(pm_issue_type: 2).joins(:issue_participants).where(issue_participants: {participant_id: current_user.id, participant_type: 'assigned'}).size
@my_assign_bugs_count = @all_issues.where(pm_issue_type: 3).joins(:issue_participants).where(issue_participants: {participant_id: current_user.id, participant_type: 'assigned'}).size
end
def my_pm_projects
return render_error('请输入正确的pm_project_id.') if params[:pm_project_id].blank?
@all_issues = Issue.where(pm_project_id: params[:pm_project_id])
time_now = Time.now
@last_week_create_issues_count = @all_issues.where("created_on > ? and created_on < ?", time_now - 7.days, time_now).size
@before_last_week_create_issue_count = @all_issues.where("created_on > ? and created_on < ?", time_now - 14.days, time_now - 7.days).size
@compare_last_week_create_issues = @before_last_week_create_issue_count.zero? ? 0 :(@last_week_create_issues_count - @before_last_week_create_issue_count).to_f / @before_last_week_create_issue_count rescue 0
@last_week_close_issues_count = @all_issues.where(status_id: 5).where("updated_on > ? and updated_on < ?", time_now - 7.days, time_now).size
@before_last_week_close_issue_count = @all_issues.where(status_id: 5).where("updated_on > ? and updated_on < ?", time_now - 14.days, time_now - 7.days).size
@compare_last_week_close_issues = @before_last_week_close_issue_count.zero? ? 0 :(@last_week_close_issues_count - @before_last_week_close_issue_count).to_f / @before_last_week_close_issue_count rescue 0
@all_requirement_issues_count = @all_issues.where(pm_issue_type: 1).size
@open_requirement_issues_count = @all_issues.where(pm_issue_type: 1).where.not(status_id: 5).size
@last_week_close_requirement_issues_count = @all_issues.where(pm_issue_type: 1).where(status_id: 5).where("updated_on > ? and updated_on < ?", time_now - 7.days, time_now).size
@last_month_close_requirement_issues_count = @all_issues.where(pm_issue_type: 1).where(status_id: 5).where("updated_on > ? and updated_on < ?", time_now - 30.days, time_now).size
@all_task_issues_count = @all_issues.where(pm_issue_type: 2).size
@open_task_issues_count = @all_issues.where(pm_issue_type: 2).where.not(status_id: 5).size
@last_week_close_tast_issues_count = @all_issues.where(pm_issue_type: 2).where(status_id: 5).where("updated_on > ? and updated_on < ?", time_now - 7.days, time_now).size
@last_month_close_task_issues_count = @all_issues.where(pm_issue_type: 2).where(status_id: 5).where("updated_on > ? and updated_on < ?", time_now - 30.days, time_now).size
@all_bug_issues_count = @all_issues.where(pm_issue_type: 3).size
@open_bug_issues_count = @all_issues.where(pm_issue_type: 3).where.not(status_id: 5).size
@last_week_close_bug_issues_count = @all_issues.where(pm_issue_type: 3).where(status_id: 5).where("updated_on > ? and updated_on < ?", time_now - 7.days, time_now).size
@last_month_close_bug_issues_count = @all_issues.where(pm_issue_type: 3).where(status_id: 5).where("updated_on > ? and updated_on < ?", time_now - 30.days, time_now).size
@requirement_close_trend = [[],[]]
@task_close_trend = [[],[]]
@bug_close_trend = [[],[]]
((time_now-29.days).to_date..time_now.to_date).to_a.each do |i|
@requirement_close_trend[0] << i.strftime("%Y.%m.%d")
@task_close_trend[0] << i.strftime("%Y.%m.%d")
@bug_close_trend[0] << i.strftime("%Y.%m.%d")
@requirement_close_trend[1] << @all_issues.where(pm_issue_type: 1, status_id: 5).where("DATE(updated_on) = ?", i).size
@task_close_trend[1] << @all_issues.where(pm_issue_type: 2, status_id: 5).where("DATE(updated_on) = ?", i).size
@bug_close_trend[1] << @all_issues.where(pm_issue_type: 3, status_id: 5).where("DATE(updated_on) = ?", i).size
end
@close_trend = {requirement: @requirement_close_trend, task: @task_close_trend, bug: @bug_close_trend}
render_ok(data: {
last_week_close_issues_count: @last_week_close_issues_count,
before_last_week_close_issue_count: @before_last_week_close_issue_count,
compare_last_week_close_issues: @compare_last_week_close_issues,
last_week_create_issues_count: @last_week_create_issues_count,
before_last_week_create_issue_count: @before_last_week_create_issue_count,
compare_last_week_create_issues: @compare_last_week_create_issues,
all_requirement_issues_count: @all_requirement_issues_count,
open_requirement_issues_count: @open_requirement_issues_count,
last_week_close_requirement_issues_count: @last_week_close_requirement_issues_count,
last_month_close_requirement_issues_count: @last_month_close_requirement_issues_count,
all_task_issues_count: @all_task_issues_count,
open_task_issues_count: @open_task_issues_count,
last_week_close_task_issues_count: @last_week_close_tast_issues_count,
last_month_close_task_issues_count: @last_month_close_task_issues_count,
all_bug_issues_count: @all_bug_issues_count,
open_bug_issues_count: @open_bug_issues_count,
last_week_close_bug_issues_count: @last_week_close_bug_issues_count,
last_month_close_bug_issues_count: @last_month_close_bug_issues_count,
close_trend: @close_trend
})
end
def my_projects
return render_error('请输入正确的project_id.') if params[:project_id].blank?
@project = Project.find_by_id params[:project_id]
return render_error('请输入正确的project_id.') unless @project.present?
time_now = Time.now
branch_tag_result = $gitea_hat_client.get_repos_branch_tag_count_by_owner_repo(@project&.owner&.login, @project&.identifier) rescue {}
languages_result = $gitea_client.get_repos_languages_by_owner_repo(@project&.owner&.login, @project&.identifier) rescue {}
@open_pull_requests_count = @project.pull_requests.opening.size
@last_week_close_pull_requests_count = @project.pull_requests.where(status: 1).where("updated_at > ? and updated_at < ?", time_now - 7.days, time_now).size
@last_month_close_pull_requets_count = @project.pull_requests.where(status: 1).where("updated_at > ? and updated_at < ?", time_now - 30.days, time_now).size
@commits_count = @project.commit_logs.size
@last_week_commits_count = @project.commit_logs.where("created_at > ? and created_at < ?", time_now - 7.days, time_now).size
@last_month_commits_count = @project.commit_logs.where("created_at > ? and created_at < ?", time_now - 30.days, time_now).size
render_ok(data: {
branch_count: branch_tag_result["branch_count"].to_i,
tag_count: branch_tag_result["tag_count"].to_i,
license_name: @project.license&.name,
open_pull_requests_count: @open_pull_requests_count,
last_week_close_pull_requests_count: @last_week_close_pull_requests_count,
last_month_close_pull_requets_count: @last_month_close_pull_requets_count,
commits_count: @commits_count,
last_week_commits_count: @last_week_commits_count,
last_month_commits_count: @last_month_commits_count,
language: hash_transform_precentagable(languages_result),
})
end
def my_operate_journals
return render_error('请输入正确的pm_project_id.') if params[:pm_project_id].blank?
@journals = Journal.operate_journals.joins(:issue).where(issues: {pm_project_id: params[:pm_project_id], pm_issue_type: [1,2,3]})
@journals = kaminari_paginate(@journals.order(updated_on: :desc))
end
private
def hash_transform_precentagable(hash)
total_byte_size = hash.values.sum
hash.transform_values { |v|
ActionController::Base.helpers
.number_to_percentage((v * 100.0 / total_byte_size), precision: 1)
}.select{|k,v| v != "0.0%"}
end
end

View File

@ -237,65 +237,18 @@ class Api::Pm::IssuesController < Api::Pm::BaseController
end
end
def link_issues
children_issues = @issue.pm_issue_type == 1 ? @issue.child_count > 0 ? Issue.where(id: @issue.id) : Issue.none : Issue.where(root_id: @issue.id)
linkable_issues = Issue.where(id: PmLink.where(linkable_type: "Issue", linkable_id: @issue.id).pluck(:be_linkable_id))
belinkable_issues = Issue.where(id: PmLink.where(be_linkable_type: "Issue", be_linkable_id: @issue.id).pluck(:linkable_id))
full_link_issues_ids = children_issues.pluck(:id) | linkable_issues.pluck(:id) | belinkable_issues.pluck(:id)
compare_link_issues_ids = children_issues.pluck(:id) | linkable_issues.pluck(:id) | belinkable_issues.pluck(:id)
i = compare_link_issues_ids.count
while i > 0 do
children_issues = Issue.where(root_id: compare_link_issues_ids)
linkable_issues = Issue.where(id: PmLink.where(linkable_type: "Issue", linkable_id: compare_link_issues_ids).pluck(:be_linkable_id))
belinkable_issues = Issue.where(id: PmLink.where(be_linkable_type: "Issue", be_linkable_id: compare_link_issues_ids).pluck(:linkable_id))
compare_link_issues_ids = (children_issues.pluck(:id) | linkable_issues.pluck(:id) | belinkable_issues.pluck(:id)) - full_link_issues_ids
full_link_issues_ids = full_link_issues_ids | compare_link_issues_ids
i = compare_link_issues_ids.count
end
exclude_issues_ids = []
exclude_issues = Issue.where(id: full_link_issues_ids).where.not(root_id: nil)
exclude_issues.each do |i|
exclude_issues_ids << i.id if i.pm_issue_type == 1 && full_link_issues_ids.include?(i.root_id)
end
full_link_issues_ids = full_link_issues_ids - exclude_issues_ids
@requirement_issues = Issue.where(id:full_link_issues_ids, pm_issue_type:1, root_id: nil).pm_includes
@task_issues = Issue.where(id:full_link_issues_ids, pm_issue_type:2).pm_includes
@bug_issues = Issue.where(id:full_link_issues_ids, pm_issue_type:3).pm_includes
end
private
def circle_link_issues(issue_ids)
if issue_ids.present?
children_issues = Issue.joins(:parent_issue).where(issues: {id: issue_ids})
linkable_issues = Issue.where(id: PmLink.where(linkable_type: "Issue", linkable_id: issue_ids))
belinkable_issues = Issue.where(id: PmLink.where(be_linkable_type: "Issue", be_linkable_id: issue_ids))
return circle_link_issues(children_issues.pluck(:id))
else
return []
end
end
def check_issue_operate_permission
return if params[:project_id].to_i.zero?
render_forbidden('您没有操作权限!') unless @project.member?(current_user) || current_user.admin? || @issue.user == current_user
end
def load_issue
# return render_parameter_missing if params[:pm_project_id].blank?
@issue = Issue.issue_issue.find_by_id(params[:id])
return render_parameter_missing if params[:pm_project_id].blank?
@issue = Issue.issue_issue.where(pm_project_id: params[:pm_project_id]).find_by_id(params[:id])
render_not_found('疑修不存在!') if @issue.blank?
end
# def load_issue_by_index
# return render_parameter_missing if params[:pm_project_id].blank? || params[:pm_issue_type].blank? || params[:enterprise_identifier].blank?
# @issue = Issue.find_issues_by_pm(params[:enterprise_identifier], params[:pm_issue_type])
# .find_by(pm_issue_type_index3: params[:index])
# render_not_found('疑修不存在!') if @issue.blank?
# end
def load_issues
return render_error('请输入正确的ID数组') unless params[:ids].is_a?(Array)
params[:ids].each do |id|
@ -322,7 +275,7 @@ class Api::Pm::IssuesController < Api::Pm::BaseController
:update_begin_date, :update_end_date,
:sort_by, :sort_direction, :root_id,
:issue_tag_ids, :pm_project_id, :pm_sprint_id, :pm_issue_type, :pm_project_ids,
:status_ids, :ids, :exclude_ids, :pm_issue_types, :participator_id, :enterprise_identifier
:status_ids, :ids, :exclude_ids, :pm_issue_types, :participator_id
)
end
@ -334,7 +287,6 @@ class Api::Pm::IssuesController < Api::Pm::BaseController
:branch_name, :start_date, :due_date, :time_scale,
:subject, :description, :blockchain_token_num, :root_subject,
:pm_project_id, :pm_sprint_id, :pm_issue_type, :root_id, :link_able_id, :project_id,
:status_msg, :enterprise_identifier,
issue_tag_ids: [],
assigner_ids: [],
attachment_ids: [],

View File

@ -1,77 +0,0 @@
class Api::Pm::PipelinesController < Api::Pm::BaseController
include RepositoriesHelper
def index
@owner = Owner.find_by(login: params[:owner_id].to_s) || Owner.find_by(id: params[:owner_id].to_s)
tip_exception('组织未找到') if @owner.blank?
unless @owner.is_a?(Organization) && @owner.is_member?(current_user.id)
tip_exception('没有查看组织的权限')
end
@project_ids = @owner.projects.ids
project_gpids = @owner.projects.pluck(:gpid)
action_runs = Gitea::ActionRun.where(owner_id: @owner.gitea_uid)
group_data = action_runs.where(status: [1,2]).group(:workflow_id, :status).count
pipelines = Action::Pipeline.where(project_id: @project_ids).order(updated_at: :desc)
run_files = Gitea::ActionRun.select(:workflow_id, :repo_id).where(owner_id: @owner.gitea_uid).group(:workflow_id, :repo_id)
db_files = pipelines.pluck(:file_name)
@run_result = []
run_files.each do |file_info|
file = file_info.workflow_id
project = Project.find_by(gpid: file_info.repo_id)
next if project.blank?
unless db_files.include?(".gitea/workflows/#{file}")
pipeline = Action::Pipeline.find_or_initialize_by(pipeline_name: file.to_s.gsub(".yml", "").gsub(".yaml", ""),
file_name: ".gitea/workflows/#{file}",
branch: project.default_branch,
is_graphic_design: false,
disable: false,
project_id: project.id)
interactor = Repositories::EntriesInteractor.call(@owner, project.identifier, ".gitea/workflows/#{file}", ref: project.default_branch)
if interactor.success?
pipeline.yaml = decode64_content(interactor.result, @owner, project.repository, project.default_branch, nil)
end
pipeline.user_id = current_user.id
pipeline.save
# 导入的流水线统一先禁用
$gitea_hat_client.post_repos_actions_disable(project&.owner&.login, project&.identifier, {query: {workflow: file}}) rescue nil
end
last_action_run = action_runs.where(repo_id: project.gpid).where(workflow_id: file).order(updated: :desc).first
last_action_run_json = last_action_run.present? ? {
id: last_action_run.id,
schedule: last_action_run.schedule_id > 0,
title: last_action_run.title,
index: last_action_run.index,
status: last_action_run.status,
started: last_action_run.started,
stopped: last_action_run.stopped,
length: last_action_run.stopped-last_action_run.started,
created: last_action_run.created,
updated: last_action_run.updated,
} : {}
total = 0
success = 0
failure = 0
group_data.each do |k,v|
total += v if k[0] == file
success += v if k[0] == file && k[1] == 1
failure += v if k[0] == file && k[1] == 2
end
@run_result << {
repo_id: last_action_run.repo_id,
filename: ".gitea/workflows/#{file}",
total: total,
success: success,
failure: failure
}.merge(last_action_run_json)
end
# Rails.logger.info("@run_result======#{@run_result}")
@disabled_workflows = Gitea::RepoUnit.where(repo_id: project_gpids, type: 10).where("config is not null")
@pipelines = Action::Pipeline.select("distinct project_id,max(updated_at) as updated_at")
.where(project_id: @project_ids).group(:project_id).order("updated_at desc")
@pipelines = @pipelines.where("pipeline_name like ?", "%#{params[:pipeline_name]}%") if params[:pipeline_name].present?
@pipelines = @pipelines.where(pipeline_type: params[:pipeline_type]) if params[:pipeline_type].present?
@pipelines = kaminari_paginate(@pipelines)
end
end

View File

@ -56,15 +56,12 @@ class Api::Pm::ProjectsController < Api::Pm::BaseController
def statistics
return tip_exception '参数错误' if params[:pm_project_id].blank?
@issues = Issue.where(pm_project_id: params[:pm_project_id], pm_issue_type:[1, 2, 3])
@last_week_close_issues = @issues.where(status_id: 5).where("updated_on > ? and updated_on < ?", Time.now - 7.days, Time.now)
last_week_close_type_count_data = @last_week_close_issues.group(:pm_issue_type).count
type_count_data = @issues.group(:pm_issue_type).count
type_status = @issues.group(:pm_issue_type,:status_id).count
type_status_data = {}
IssueStatus.all.map do |e|
# next if e.id == 5
[1,2,3].map{ |type|
next if type == 1 && [1, 6].include?(e.id)
type_status_data[type] = {} if type_status_data[type].nil?
if type_status[[type,e.id]].nil?
type_status_data[type][e.id] = 0
@ -74,9 +71,9 @@ class Api::Pm::ProjectsController < Api::Pm::BaseController
}
end
open_data = {
"1": type_status_data[1][1].to_i + type_status_data[1][2].to_i + type_status_data[1][3].to_i + type_status_data[1][6].to_i,
"2": type_status_data[2][1].to_i + type_status_data[2][2].to_i + type_status_data[2][3].to_i + type_status_data[2][6].to_i,
"3": type_status_data[3][1].to_i + type_status_data[3][2].to_i + type_status_data[3][3].to_i + type_status_data[3][6].to_i,
"1": type_status_data[1][1].to_i + type_status_data[1][2].to_i,
"2": type_status_data[2][1].to_i + type_status_data[2][2].to_i,
"3": type_status_data[3][1].to_i + type_status_data[3][2].to_i,
}
if type_count_data.keys.size < 3
nedd_add = [1,2,3] - type_count_data.keys
@ -84,24 +81,17 @@ class Api::Pm::ProjectsController < Api::Pm::BaseController
type_count_data[e] = 0
}
end
if last_week_close_type_count_data.keys.size < 3
nedd_add = [1,2,3] - last_week_close_type_count_data.keys
nedd_add.map{ |e|
last_week_close_type_count_data[e] = 0
}
end
data = {
pie_chart: type_count_data,
bar_chart: type_status_data,
open_data: open_data,
last_week_close_data: last_week_close_type_count_data,
open_data: open_data
}
render_ok(data: data)
end
def polyline
return tip_exception '参数错误' if params[:pm_project_id].blank?
time_line = (Time.current.beginning_of_day - 29.day) .. Time.current
time_line = (Time.current.beginning_of_day - 6.day) .. Time.current
@create_issues = Issue.where(pm_project_id: params[:pm_project_id],created_on: time_line)
@due_issues = Issue.where(pm_project_id: params[:pm_project_id],status_id:[3,5],due_date: time_line)
@create_issues_count = @create_issues.group(:pm_issue_type,"DATE(created_on)").count
@ -110,7 +100,7 @@ class Api::Pm::ProjectsController < Api::Pm::BaseController
create_issues: {},
due_issues: {}
}
30.times do |time|
7.times do |time|
current_time = Date.current - time.day
if @create_issues_count.present?
data[:create_issues][current_time] = {

View File

@ -71,7 +71,7 @@ class Api::Pm::SprintIssuesController < Api::Pm::BaseController
begin
case complete_params[:complete_type].to_i
when 1
@issues.update_all(status_id: 5, due_date: Time.now)
@issues.update_all(status_id: 5)
when 2
@issues.update_all(pm_sprint_id: 0)
when 3

View File

@ -1,82 +0,0 @@
class Api::Pm::WeeklyIssuesController < Api::Pm::BaseController
def personal
@enterprise_identifier = params[:enterprise_identifier] || ''
return render_error('请输入正确的用户ID.') if params[:user_id].blank?
@all_issues = Issue.joins(:issue_participants).where(issue_participants: {participant_id: params[:user_id], participant_type: ['assigned']})
@all_issues = @all_issues.where(enterprise_identifier: @enterprise_identifier, pm_issue_type: [1,2,3])
@this_week_all_issues = @all_issues.where("due_date >= ? and start_date <= ?", Date.today.beginning_of_week.to_s, Date.today.end_of_week.to_s).distinct
@this_week_all_issues = @this_week_all_issues.order('created_on desc')
@next_week_all_issues = @all_issues.where("due_date >= ? and start_date <=?", (Date.today.beginning_of_week+1.week).to_s, (Date.today.end_of_week+1.week).to_s).distinct
@next_week_all_issues = @next_week_all_issues.order('created_on desc')
@this_week_requirement_issues = @this_week_all_issues.where(pm_issue_type: 1)
@this_week_task_issues = @this_week_all_issues.where(pm_issue_type: 2)
@this_week_bug_issues = @this_week_all_issues.where(pm_issue_type: 3)
@close_requirement_issues = @this_week_requirement_issues.where(status_id: [3,5])
@close_task_issues = @this_week_task_issues.where(status_id: [3,5])
@close_bug_issues = @this_week_bug_issues.where(status_id: [3,5])
this_week_page = params[:this_week_page] || 1
this_week_limit = params[:this_week_limit] || 15
@this_week_all_issues = @this_week_all_issues.page(this_week_page).per(this_week_limit)
next_week_page = params[:next_week_page] || 1
next_week_limit = params[:next_week_limit] || 15
@next_week_all_issues = @next_week_all_issues.page(next_week_page).per(next_week_limit)
end
def group
@enterprise_identifier = params[:enterprise_identifier] || ''
@all_issues = Issue.where(enterprise_identifier: @enterprise_identifier, pm_issue_type: [1,2,3])
@all_issues = @all_issues.where(pm_project_id: params[:pm_project_ids].split(",")) if params[:pm_project_ids].present?
@this_week_all_issues = @all_issues.where("due_date >= ? and start_date <= ?", Date.today.beginning_of_week.to_s, Date.today.end_of_week.to_s)
@this_week_all_issues_group_count = @this_week_all_issues.group(:pm_project_id).count
data = {}
@this_week_all_issues_group_count.keys.each do |pm_project_id|
this_project_id_requirements = @this_week_all_issues.where(pm_project_id: pm_project_id, pm_issue_type: 1)
this_project_id_tasks = @this_week_all_issues.where(pm_project_id: pm_project_id, pm_issue_type: 2)
this_project_id_bugs = @this_week_all_issues.where(pm_project_id: pm_project_id, pm_issue_type: 3)
this_project_id_close_requirements = this_project_id_requirements.where(status_id: [3,5])
this_project_id_close_tasks = this_project_id_tasks.where(status_id: [3,5])
this_project_id_close_bugs = this_project_id_bugs.where(status_id: [3,5])
data[pm_project_id] = {
this_week_requirement_issues_count: this_project_id_requirements.count,
this_week_task_issues_count: this_project_id_tasks.count,
this_week_bug_issues_count: this_project_id_bugs.count,
close_requirement_issues_count: this_project_id_close_requirements.count,
close_task_issues_count: this_project_id_close_tasks.count,
close_bug_issues_count: this_project_id_close_bugs.count,
this_week_task_issues: this_project_id_tasks
}
end
render :json => data
end
def group_issues
@enterprise_identifier = params[:enterprise_identifier] || ''
@all_issues = Issue.where(enterprise_identifier: @enterprise_identifier, pm_issue_type: [1,2,3])
@all_issues = @all_issues.where(pm_project_id: params[:pm_project_ids].split(",")) if params[:pm_project_ids].present?
@all_issues = @all_issues.where(pm_issue_type: params[:pm_issue_type].to_i) if params[:pm_issue_type].present?
@this_week_all_issues = @all_issues.where("due_date >= ? and start_date <= ?", Date.today.beginning_of_week.to_s, Date.today.end_of_week.to_s)
@this_week_all_issues = @this_week_all_issues.order('created_on desc')
@this_week_all_issues = kaminari_paginate(@this_week_all_issues)
end
def personal_issues
@enterprise_identifier = params[:enterprise_identifier] || ''
return render_error('请输入正确的用户ID.') if params[:user_id].blank?
@all_issues = Issue.joins(:issue_participants).where(issue_participants: {participant_id: params[:user_id], participant_type: ['assigned']})
@all_issues = @all_issues.where(enterprise_identifier: @enterprise_identifier, pm_issue_type: [1,2,3])
@this_week_all_issues = @all_issues.where("due_date >= ? and start_date <= ?", Date.today.beginning_of_week.to_s, Date.today.end_of_week.to_s).distinct
@this_week_all_issues = @this_week_all_issues.order('created_on desc')
@next_week_all_issues = @all_issues.where("due_date >= ? and start_date <=?", (Date.today.beginning_of_week+1.week).to_s, (Date.today.end_of_week+1.week).to_s).distinct
@next_week_all_issues = @next_week_all_issues.order('created_on desc')
this_week_page = params[:this_week_page] || 1
this_week_limit = params[:this_week_limit] || 15
@this_week_all_issues = @this_week_all_issues.page(this_week_page).per(this_week_limit)
next_week_page = params[:next_week_page] || 1
next_week_limit = params[:next_week_limit] || 15
@next_week_all_issues = @next_week_all_issues.page(next_week_page).per(next_week_limit)
end
end

View File

@ -1,6 +1,6 @@
class Api::V1::IssuesController < Api::V1::BaseController
before_action :require_login, except: [:index, :show, :show_by_id]
before_action :require_public_and_member_above, only: [:index, :show, :show_by_id, :create, :update, :destroy]
before_action :require_public_and_member_above, only: [:index, :show, :show_by_id, :create, :update, :destroy]
before_action :require_operate_above, only: [:batch_update, :batch_destroy]
def index
@ -24,7 +24,7 @@ class Api::V1::IssuesController < Api::V1::BaseController
before_action :check_issue_operate_permission, only: [:update, :destroy]
before_action :load_issue_by_id, only: [:show_by_id]
def show_by_id
def show_by_id
@issue.associate_attachment_container
@user_permission = current_user.present? && current_user.logged? && (@project.member?(current_user) || current_user.admin? || @issue.user == current_user)
end
@ -76,9 +76,9 @@ class Api::V1::IssuesController < Api::V1::BaseController
end
end
def load_issue_by_id
def load_issue_by_id
@issue = Issue.find_by_id(params[:index])
if @issue.blank?
if @issue.blank?
render_not_found("疑修不存在!")
end
end

View File

@ -1,67 +1,5 @@
class Api::V1::Projects::Actions::ActionsController < Api::V1::Projects::Actions::BaseController
def new_index
@files = $gitea_client.get_repos_contents_by_owner_repo_filepath(@project&.owner&.login, @project&.identifier, ".gitea/workflows") rescue []
@workflows = params[:workflows].split(",") if params[:workflows].present?
@action_runs = Gitea::ActionRun.where(repo_id: @project.gpid)
disabled_config = Gitea::RepoUnit.where(repo_id: @project.gpid, type: 10)&.first&.config
disabled_workflows = disabled_config.present? ? JSON.parse(disabled_config)["DisabledWorkflows"] : []
@action_runs = @action_runs.where(id: params[:ids].split(",")) if params[:ids].present?
@action_runs = @action_runs.where(workflow_id: @workflows) if params[:workflows].present?
group_data = @action_runs.where(status: [1,2]).group(:workflow_id, :status).count
@result = []
@files.map{|i|i['name']}.each do |file|
if @workflows.present?
next if !@workflows.include?(file)
end
last_action_run = @action_runs.where(workflow_id: file).order(updated: :desc).first
last_action_run_json = last_action_run.present? ? {
pipeline_id: Action::Pipeline.find_by(pipeline_name: file, project_id: @project.id),
id: last_action_run.id,
schedule: last_action_run.schedule_id > 0,
title: last_action_run.title,
index: last_action_run.index,
status: last_action_run.status,
started: last_action_run.started,
stopped: last_action_run.stopped,
length: last_action_run.stopped-last_action_run.started,
created: last_action_run.created,
updated: last_action_run.updated,
} : {}
total = 0
success = 0
failure = 0
group_data.each do |k,v|
total += v if k[0] == file
success += v if k[0] == file && k[1] == 1
failure += v if k[0] == file && k[1] == 2
end
pipeline_type = 1
begin
content = Gitea::Repository::Entries::GetService.call(@project&.owner, @project&.identifier, URI.escape(file), ref: last_action_run.present? ? last_action_run.ref.gsub("refs/heads/","") : @project.default_branch)['content']
yaml_string = Base64.decode64(content).force_encoding("GBK").encode("UTF-8") unless Base64.decode64(content).force_encoding('UTF-8').valid_encoding?
yaml_string = Base64.decode64(content).force_encoding('UTF-8')
yml = YAML.safe_load(yaml_string)
pipeline_type = yml.name == file.to_s.gsub(".yml","").gsub(".yaml","") ? 2 : 1
rescue
Rails.logger.info("#{file}不能识别流水线类型")
end
@result << {
filename: file,
disabled: disabled_workflows.include?(file.to_s),
name: file.to_s.gsub(".yml","").gsub(".yaml","") ,
branch: last_action_run.present? ? last_action_run.ref.gsub("refs/heads/","") : @project.default_branch,
pipeline_type: pipeline_type,
total: total,
success: success,
failure: failure
}.merge(last_action_run_json)
end
render :json => {data: @result}
end
def index
begin
gitea_result = $gitea_hat_client.get_repos_actions_by_owner_repo(@project&.owner&.login, @project&.identifier)

View File

@ -1,12 +1,8 @@
class Api::V1::Projects::Actions::RunsController < Api::V1::Projects::Actions::BaseController
def index
@files = $gitea_client.get_repos_contents_by_owner_repo_filepath(@project&.owner&.login, @project&.identifier, ".gitea/workflows") rescue []
@has_file = @files.select { |i| i['name'] == params[:workflow] }.present?
if @has_file
@result_object = Api::V1::Projects::Actions::Runs::ListService.call(@project, {workflow: params[:workflow], page: page, limit: limit}, current_user&.gitea_token)
@begin_num = (page.to_i - 1) * limit.to_i
end
def index
@result_object = Api::V1::Projects::Actions::Runs::ListService.call(@project, {workflow: params[:workflow], page: page, limit: limit}, current_user&.gitea_token)
puts @result_object
end
def create

View File

@ -36,13 +36,11 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController
def create
@result_object = Api::V1::Projects::Branches::CreateService.call(@project, branch_params, current_user&.gitea_token)
@project.update_column(:updated_on, Time.now)
end
def destroy
@result_object = Api::V1::Projects::Branches::DeleteService.call(@project, params[:name], current_user&.gitea_token)
if @result_object
@project.update_column(:updated_on, Time.now)
# 有开启的pr需要一同关闭
# 1、删除本仓库中存在未关闭的pr,即本仓库分支1->分支2
# 2、如果是fork仓库考虑删除主仓库中存在未关闭的pr,即本仓库分支1->主分支2同时分两种删除1删除本仓库分支12删除主仓库分支2
@ -61,7 +59,6 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController
def restore
@result_object = Api::V1::Projects::Branches::RestoreService.call(@project, params[:branch_id], params[:branch_name], current_user&.gitea_token)
if @result_object
@project.update_column(:updated_on, Time.now)
return render_ok
else
return render_error('恢复分支失败!')
@ -73,7 +70,6 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController
def update_default_branch
@result_object = Api::V1::Projects::Branches::UpdateDefaultBranchService.call(@project, params[:name], current_user&.gitea_token)
if @result_object
@project.update_column(:updated_on, Time.now)
return render_ok
else
return render_error('更新默认分支失败!')

View File

@ -20,9 +20,9 @@ class Api::V1::Projects::CompareController < Api::V1::BaseController
def gitea_compare_files(base, head)
if params[:filepath].present?
$gitea_hat_client.get_repos_compare_by_owner_repo_baseref_headref(@project&.owner&.login, @project.identifier, Addressable::URI.escape(base), Addressable::URI.escape(head), {query: {token: current_user&.gitea_token, isFiles: true, filepath: params[:filepath]}})
$gitea_hat_client.get_repos_compare_files_by_owner_repo_baseref_headref_filepath(@project&.owner&.login, @project.identifier, Addressable::URI.escape(base), Addressable::URI.escape(head), CGI.escape(params[:filepath]), {query: {token: current_user&.gitea_token}})
else
$gitea_hat_client.get_repos_compare_by_owner_repo_baseref_headref(@project&.owner&.login, @project.identifier, Addressable::URI.escape(base), Addressable::URI.escape(head), {query: {page:page,limit:limit,token: current_user&.gitea_token, isFiles: true}})
$gitea_hat_client.get_repos_compare_files_by_owner_repo_baseref_headref(@project&.owner&.login, @project.identifier, Addressable::URI.escape(base), Addressable::URI.escape(head), {query: {page:page,limit:limit,token: current_user&.gitea_token}})
end
end

File diff suppressed because it is too large Load Diff

View File

@ -2,203 +2,51 @@ class Api::V1::Projects::PortraitController < Api::V1::BaseController
before_action :require_public_and_member_above
def index
Cache::V2::PlatformStatisticService.new().reset
@platform_statistic = $redis_cache.hgetall("v2-platform-statistic")
platform_statistic = $redis_cache.hgetall("v2-platform-statistic")
# 社区影响力
praise_count = PraiseTread.where(praise_tread_object_type: "Project", praise_tread_object_id: @project.id).count
praise_count = PraiseTread.where(praise_tread_object_type: "Project", praise_tread_object_id: @project.id).count
watcher_count = Watcher.where(watchable_type:"Project", watchable_id: @project.id).count
fork_count = ForkUser.where(project_id: @project.id).count
community_impact_praise = @platform_statistic['max-praise-count'].to_i == 0 ? 0 : 30*(praise_count.to_f/@platform_statistic['max-praise-count'].to_i)
community_impact_watcher = @platform_statistic['max-watcher-count'].to_i == 0 ? 0 : 30*(watcher_count.to_f/@platform_statistic['max-watcher-count'].to_i)
community_impact_fork = @platform_statistic['max-fork-count'].to_i == 0 ? 0 : 40*(fork_count.to_f/@platform_statistic['max-fork-count'].to_i)
community_impact_praise = platform_statistic['max-praise-count'].to_i == 0 ? 0 : 30*(praise_count.to_f/platform_statistic['max-praise-count'].to_i)
community_impact_watcher = platform_statistic['max-watcher-count'].to_i == 0 ? 0 : 30*(watcher_count.to_f/platform_statistic['max-watcher-count'].to_i)
community_impact_fork = platform_statistic['max-fork-count'].to_i == 0 ? 0 : 40*(fork_count.to_f/platform_statistic['max-fork-count'].to_i)
community_impact = format("%.2f", community_impact_praise + community_impact_watcher + community_impact_fork)
# 项目成熟度
pullrequest_count = PullRequest.where(project_id: @project.id).count
complete_issue_count = Issue.issue_issue.where(project_id: @project.id, status_id: [3,5]).count
project_create_day = (Time.now.to_i - @project.created_on.to_i)/(3600*24)
max_project_create_day = (Time.now.to_i - Project.order("created_on desc").last.created_on.to_i)/(3600*24)
project_maturity_pullrequest = @platform_statistic['max-pullrequest-count'].to_i == 0? 0 : 40*(pullrequest_count.to_f/@platform_statistic['max-pullrequest-count'].to_i)
project_maturity_complete_issue = @platform_statistic['max-complete-issue-count'].to_i == 0? 0 : 40*(complete_issue_count.to_f/@platform_statistic['max-complete-issue-count'].to_i)
project_maturity_project_create_day = max_project_create_day.to_i <= 0 || project_create_day.to_i <= 0 ? 0 : 20*(Math.sqrt(project_create_day).to_f/Math.sqrt(max_project_create_day))
project_maturity = format("%.2f", project_maturity_pullrequest + project_maturity_complete_issue + project_maturity_project_create_day)
pullrequest_count = PullRequest.where(project_id: @project.id).count
issue_count = Issue.issue_issue.where(project_id: @project.id).count
commit_count = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).count
project_maturity_pullrequest = platform_statistic['max-pullrequest-count'].to_i == 0 ? 0 : 30*(pullrequest_count.to_f/platform_statistic['max-pullrequest-count'].to_i)
project_maturity_issue = platform_statistic['max-issue-count'].to_i == 0 ? 0 : 30*(issue_count.to_f/platform_statistic['max-issue-count'].to_i)
project_maturity_commit = platform_statistic['max-commit-count'].to_i == 0 ? 0 : 40*(commit_count.to_f/platform_statistic['max-commit-count'].to_i)
project_maturity = format("%.2f", project_maturity_pullrequest + project_maturity_issue + project_maturity_commit)
# 项目健康度
member_count = Member.where(project_id: @project.id).count
max_member_count = @platform_statistic['max-member-count'].to_i
project_last_commit = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).order("created_at desc").first
last_commit_day = project_last_commit.present? ? (Time.now.to_i - project_last_commit.created_at.to_i)/(3600*24) : 0
closed_pullrequest_count = PullRequest.where(project_id: @project.id).merged_and_closed.count
closed_issue_count = Issue.issue_issue.where(project_id: @project.id).closed.count
has_license = @project.license.present? ? 1 : 0
closed_pullrequest_count = PullRequest.where(project_id: @project.id).merged_and_closed.count
closed_issue_count = Issue.issue_issue.where(project_id: @project.id).closed.count
pullrequest_count = PullRequest.where(project_id: @project.id).count
issue_count = Issue.issue_issue.where(project_id: @project.id).count
health_code1 = max_member_count.to_i == 0 ? 0 : 0.3*(member_count.to_f/max_member_count)
health_code2 = last_commit_day.to_i == 0 ? 0 : 0.7*(1.to_f/(1+last_commit_day))
health_code = 10 * (health_code1 + health_code2)
health_license = 10 * has_license
health_pullrequest = pullrequest_count <= 1 ? 0 : 40 * (closed_pullrequest_count.to_f/pullrequest_count)*(1-1/Math.sqrt(pullrequest_count+1))
health_issue = issue_count <= 1 ? 0 : 40 * (closed_issue_count.to_f/issue_count)*(1-1/Math.sqrt(issue_count+1))
project_health = format("%.2f", health_code + health_license + health_pullrequest + health_issue)
project_health_issue = (issue_count < 10 || closed_issue_count < 10) ? 0 : 40*(closed_issue_count-10).to_f/(issue_count-10)
project_health_pullrequest = (pullrequest_count < 5 || closed_pullrequest_count < 5) ? 0 : 30*(closed_pullrequest_count-5).to_f/(pullrequest_count-5)
project_health_license = 20*has_license
project_health = format("%.2f", project_health_issue + project_health_pullrequest + project_health_license)
# 团队影响度
member_count = Member.where(project_id: @project.id).count
max_member_count = @platform_statistic['max-member-count'].to_i
recent_one_month_member_count = Member.where(project_id:@project.id).where("created_on >?", Time.now - 30.days).count
max_recent_one_month_member_count = @platform_statistic['max-recent-one-month-member-count'].to_i
issue_assigner_count = IssueAssigner.joins(:issue).merge(Issue.issue_issue).where(issues: {project_id: @project.id}).distinct.count
team_impact_member = 40*(member_count.to_f/max_member_count)
team_impact_recent_member = 40*(recent_one_month_member_count.to_f/max_recent_one_month_member_count)
team_impact_issue_assigner = 20*(issue_assigner_count.to_f/max_member_count)
team_impact = format("%.2f", team_impact_member + team_impact_recent_member + team_impact_issue_assigner)
member_count = Member.where(project_id: @project.id).count
recent_one_month_member_count = Member.where(project_id:@project.id).where("created_on > ?", Time.now - 30.days).count
team_impact_member = platform_statistic['max-member-count'].to_i == 0 ? 0 : 40*(member_count.to_f/platform_statistic['max-member-count'].to_i)
team_impact_recent_member = platform_statistic['max-recent-one-month-member-count'].to_i == 0 ? 0 : 60*(recent_one_month_member_count.to_f/platform_statistic['max-recent-one-month-member-count'].to_i)
team_impact = format("%.2f", team_impact_member + team_impact_recent_member)
# 开发活跃度
recent_one_month_commit_count = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).where("created_at >?", Time.now - 30.days).count
recent_one_month_pullrequest_count = PullRequest.where(project_id: @project.id).where("created_at >?", Time.now - 30.days).count
recent_one_month_issue_count = Issue.issue_issue.where(project_id: @project.id).where("created_on >?", Time.now - 30.days).count
recent_one_month_release_count = VersionRelease.joins(:repository).where(repositories: {project_id: @project.id}).where("created_at >?", Time.now - 30.days).count
max_recent_one_month_commit_count = @platform_statistic['max-recent-one-month-commit-count'].to_i
max_recent_one_month_pullrequest_count = @platform_statistic['max-recent-one-month-pullrequest-count'].to_i
max_recent_one_month_issue_count = @platform_statistic['max-recent-one-month-issue-count'].to_i
max_recent_one_month_release_count = @platform_statistic['max-recent-one-month-release-count'].to_i
develop_activity_commit = max_recent_one_month_commit_count.zero? ? 0 : 40*(recent_one_month_commit_count.to_f/max_recent_one_month_commit_count)
develop_activity_issue = max_recent_one_month_issue_count.zero? ? 0 : 20*(recent_one_month_issue_count.to_f/max_recent_one_month_issue_count)
develop_activity_pullrequest = max_recent_one_month_pullrequest_count.zero? ? 0 : 20*(recent_one_month_pullrequest_count.to_f/max_recent_one_month_pullrequest_count)
develop_activity_release = max_recent_one_month_release_count.zero? ? 0 : 20*(recent_one_month_release_count.to_f/max_recent_one_month_release_count)
develop_activity = format("%.2f", develop_activity_commit + develop_activity_issue + develop_activity_pullrequest + develop_activity_release)
recent_one_month_pullrequest_count = PullRequest.where(project_id: @project.id).where("created_at > ?", Time.now - 30.days).count
recent_one_month_issue_count = Issue.issue_issue.where(project_id: @project.id).where("created_on > ?", Time.now - 30.days).count
recent_one_month_commit_count = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).where("created_at > ?", Time.now - 30.days).count
develop_activity_pullrequest = platform_statistic['max-recent-one-month-pullrequest-count'].to_i == 0 ? 0 : 20*(recent_one_month_pullrequest_count.to_f/platform_statistic['max-recent-one-month-pullrequest-count'].to_i)
develop_activity_issue = platform_statistic['max-recent-one-month-issue-count'].to_i == 0 ? 0 : 20*(recent_one_month_issue_count.to_f/platform_statistic['max-recent-one-month-issue-count'].to_i)
develop_activity_commit = platform_statistic['max-recent-one-month-commit-count'].to_i == 0 ? 0 : 40*(recent_one_month_commit_count.to_f/platform_statistic['max-recent-one-month-commit-count'].to_i)
develop_activity = format("%.2f", 20 + develop_activity_pullrequest + develop_activity_issue + develop_activity_commit)
render :json => {community_impact: community_impact, project_maturity: project_maturity, project_health: project_health, team_impact: team_impact, develop_activity: develop_activity}
end
# 社区影响力
def community_impact
Cache::V2::PlatformStatisticService.new().reset
@platform_statistic = $redis_cache.hgetall("v2-platform-statistic")
praise_count = PraiseTread.where(praise_tread_object_type: "Project", praise_tread_object_id: @project.id).count
watcher_count = Watcher.where(watchable_type:"Project", watchable_id: @project.id).count
fork_count = ForkUser.where(project_id: @project.id).count
community_impact_praise = @platform_statistic['max-praise-count'].to_i == 0 ? 0 : 30*(praise_count.to_f/@platform_statistic['max-praise-count'].to_i)
community_impact_watcher = @platform_statistic['max-watcher-count'].to_i == 0 ? 0 : 30*(watcher_count.to_f/@platform_statistic['max-watcher-count'].to_i)
community_impact_fork = @platform_statistic['max-fork-count'].to_i == 0 ? 0 : 40*(fork_count.to_f/@platform_statistic['max-fork-count'].to_i)
community_impact = format("%.2f", community_impact_praise + community_impact_watcher + community_impact_fork)
render :json => {
community_impact_praise: community_impact_praise,
community_impact_watcher: community_impact_watcher,
community_impact_fork: community_impact_fork,
community_impact: community_impact
}
end
# 项目成熟度
def project_maturity
Cache::V2::PlatformStatisticService.new().reset
@platform_statistic = $redis_cache.hgetall("v2-platform-statistic")
pullrequest_count = PullRequest.where(project_id: @project.id).count
complete_issue_count = Issue.issue_issue.where(project_id: @project.id, status_id: [3,5]).count
project_create_day = (Time.now.to_i - @project.created_on.to_i)/(3600*24)
max_project_create_day = (Time.now.to_i - Project.order("created_on desc").last.created_on.to_i)/(3600*24)
project_maturity_pullrequest = @platform_statistic['max-pullrequest-count'].to_i == 0? 0 : 40*(pullrequest_count.to_f/@platform_statistic['max-pullrequest-count'].to_i)
project_maturity_complete_issue = @platform_statistic['max-complete-issue-count'].to_i == 0? 0 : 40*(complete_issue_count.to_f/@platform_statistic['max-complete-issue-count'].to_i)
project_maturity_project_create_day = max_project_create_day.to_i <= 0 || project_create_day.to_i <= 0 ? 0 : 20*(Math.sqrt(project_create_day).to_f/Math.sqrt(max_project_create_day))
project_maturity = format("%.2f", project_maturity_pullrequest + project_maturity_complete_issue + project_maturity_project_create_day)
render :json => {
project_maturity_pullrequest: project_maturity_pullrequest,
project_maturity_complete_issue: project_maturity_complete_issue,
project_maturity_project_create_day: project_maturity_project_create_day,
project_maturity: project_maturity
}
end
# 项目健康度
def project_health
Cache::V2::PlatformStatisticService.new().reset
@platform_statistic = $redis_cache.hgetall("v2-platform-statistic")
member_count = Member.where(project_id: @project.id).count
max_member_count = @platform_statistic['max-member-count'].to_i
project_last_commit = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).order("created_at desc").first
last_commit_day = project_last_commit.present? ? (Time.now.to_i - project_last_commit.created_at.to_i)/(3600*24) : 0
has_license = @project.license.present? ? 1 : 0
closed_pullrequest_count = PullRequest.where(project_id: @project.id, status: 1).count
closed_issue_count = Issue.issue_issue.where(project_id: @project.id, status_id: [3,5]).count
pullrequest_count = PullRequest.where(project_id: @project.id).count
issue_count = Issue.issue_issue.where(project_id: @project.id).count
health_code1 = max_member_count.to_i == 0 ? 0 : 0.3*(member_count.to_f/max_member_count)
health_code2 = last_commit_day.to_i == 0 ? 0 : 0.7*(1.to_f/(1+last_commit_day*0.1))
health_code = 10 * (health_code1 + health_code2)
health_license = 10 * has_license
health_pullrequest = pullrequest_count <= 1 ? 0 : 40 * (closed_pullrequest_count.to_f/pullrequest_count)*(1-1/Math.sqrt(pullrequest_count+1))
health_issue = issue_count <= 1 ? 0 : 40 * (closed_issue_count.to_f/issue_count)*(1-1/Math.sqrt(issue_count+1))
project_health = format("%.2f", health_code + health_license + health_pullrequest + health_issue)
render :json => {
health_code: health_code,
health_license: health_license,
health_pullrequest: health_pullrequest,
health_issue: health_issue,
project_health: project_health
}
end
# 团队健康度
def team_impact
Cache::V2::PlatformStatisticService.new().reset
@platform_statistic = $redis_cache.hgetall("v2-platform-statistic")
member_count = Member.where(project_id: @project.id).count
max_member_count = @platform_statistic['max-member-count'].to_i
recent_one_month_member_count = Member.where(project_id:@project.id).where("created_on >?", Time.now - 30.days).count
max_recent_one_month_member_count = @platform_statistic['max-recent-one-month-member-count'].to_i
issue_assigner_count = IssueAssigner.joins(:issue).merge(Issue.issue_issue).where(issues: {project_id: @project.id}).distinct.count
project_member_count = @project.owner.is_a?(User) ? member_count : @project.owner.organization_users.count
team_impact_member = 40*(member_count.to_f/max_member_count)
team_impact_recent_member = 40*(recent_one_month_member_count.to_f/max_recent_one_month_member_count)
team_impact_issue_assigner = 20*(issue_assigner_count.to_f/project_member_count)
team_impact = format("%.2f", team_impact_member + team_impact_recent_member + team_impact_issue_assigner)
render :json => {
team_impact_member: team_impact_member,
team_impact_recent_member: team_impact_recent_member,
team_impact_issue_assigner: team_impact_issue_assigner,
team_impact: team_impact
}
end
# 开发活跃度
def develop_activity
Cache::V2::PlatformStatisticService.new().reset
@platform_statistic = $redis_cache.hgetall("v2-platform-statistic")
recent_one_month_commit_count = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).where("created_at >?", Time.now - 30.days).count
recent_one_month_pullrequest_count = PullRequest.where(project_id: @project.id).where("created_at >?", Time.now - 30.days).count
recent_one_month_issue_count = Issue.issue_issue.where(project_id: @project.id).where("created_on >?", Time.now - 30.days).count
recent_one_month_release_count = VersionRelease.joins(:repository).where(repositories: {project_id: @project.id}).where("created_at >?", Time.now - 30.days).count
max_recent_one_month_commit_count = @platform_statistic['max-recent-one-month-commit-count'].to_i
max_recent_one_month_pullrequest_count = @platform_statistic['max-recent-one-month-pullrequest-count'].to_i
max_recent_one_month_issue_count = @platform_statistic['max-recent-one-month-issue-count'].to_i
max_recent_one_month_release_count = @platform_statistic['max-recent-one-month-release-count'].to_i
develop_activity_commit = max_recent_one_month_commit_count.zero? ? 0 : 40*(recent_one_month_commit_count.to_f/max_recent_one_month_commit_count)
develop_activity_issue = max_recent_one_month_issue_count.zero? ? 0 : 20*(recent_one_month_issue_count.to_f/max_recent_one_month_issue_count)
develop_activity_pullrequest = max_recent_one_month_pullrequest_count.zero? ? 0 : 20*(recent_one_month_pullrequest_count.to_f/max_recent_one_month_pullrequest_count)
develop_activity_release = max_recent_one_month_release_count.zero? ? 0 : 20*(recent_one_month_release_count.to_f/max_recent_one_month_release_count)
develop_activity = format("%.2f", develop_activity_commit + develop_activity_issue + develop_activity_pullrequest + develop_activity_release)
render :json => {
develop_activity_commit: develop_activity_commit,
develop_activity_issue: develop_activity_issue,
develop_activity_pullrequest: develop_activity_pullrequest,
develop_activity_release: develop_activity_release,
develop_activity: develop_activity
}
end
end

View File

@ -1,8 +1,5 @@
class Api::V1::SonarqubesController < Api::V1::BaseController
before_action :load_repository
include Repository::LanguagesPercentagable
include SonarService
def sonar_initialize
gitea_params = { has_actions: params[:has_actions] == 'true' ? true :false }
gitea_setting = Gitea::Repository::UpdateService.call(@owner, @project.identifier, gitea_params)
@ -20,7 +17,6 @@ class Api::V1::SonarqubesController < Api::V1::BaseController
def insert_file
checkout_url = 'https://gitlink.org.cn/KingChan/checkout@v4'
scanner_url = 'https://gitlink.org.cn/KingChan/sonarqube-scan-action@master'
doxygen_url = "https://gitlink.gitlink.net"
begin
config = Rails.application.config_for(:configuration)
sonarqube_config = config.dig('sonarqube')
@ -31,9 +27,7 @@ class Api::V1::SonarqubesController < Api::V1::BaseController
if sonarqube_config.present? && sonarqube_config['scanner'].present?
scanner_url = sonarqube_config['scanner']
end
if sonarqube_config.present? && sonarqube_config['doxygen'].present?
doxygen_url = sonarqube_config['doxygen']
end
raise 'sonar config missing' if sonarqube_config.blank?
rescue => ex
raise ex if Rails.env.production?
@ -67,9 +61,6 @@ class Api::V1::SonarqubesController < Api::V1::BaseController
with:
# Disabling shallow clones is recommended for improving the relevancy of reporting
fetch-depth: 0
- name: curl doxygen
run: |
curl -X GET #{doxygen_url}/generate?repo=#{@project.repository.url}
- name: SonarQube Scan
uses: #{scanner_url}
env:
@ -92,13 +83,11 @@ class Api::V1::SonarqubesController < Api::V1::BaseController
Gitea::CreateFileInteractor.call(@owner.gitea_token, @owner.login, sonar_scanner_content)
end
sonar_content = build_sonar_content(params[:owner], @project.id, languages_precentagable.keys)
sonar_project_content = {
filepath: 'sonar-project.properties',
branch: params[:branch],
new_branch: nil,
"content": sonar_content,
"content": "sonar.projectKey=#{params[:owner]}-#{@project.id}\nsonar.sources=.\nsonar.java.binaries=.",
"message": 'Add sonar-project.properties',
committer: {
email: @owner.mail,
@ -106,7 +95,6 @@ class Api::V1::SonarqubesController < Api::V1::BaseController
},
identifier: @project.identifier
}
sonar_project_exit = Repositories::EntriesInteractor.call(@owner, @project.identifier, 'sonar-project.properties', ref: params[:branch])
if sonar_project_exit.success?
Gitea::UpdateFileInteractor.call(@owner.gitea_token, @owner.login, sonar_project_content.merge(sha:sonar_project_exit.result['sha']))
@ -160,31 +148,6 @@ class Api::V1::SonarqubesController < Api::V1::BaseController
render_ok data
end
def doxygen_url
config = Rails.application.config_for(:configuration)
sonarqube_config = config.dig('sonarqube')
doxygen_url = sonarqube_config['doxygen']
data = {doxygen_url: "#{doxygen_url}/files/#{@project.owner.login}/#{@project.identifier}/html/"}
render_ok data
end
def analyze_doxygen
config = Rails.application.config_for(:configuration)
sonarqube_config = config.dig('sonarqube')
doxygen_url = sonarqube_config['doxygen']
url = "#{doxygen_url}/files/#{@project.owner.login}/#{@project.identifier}/html/analyze_doxygen.json"
uri = URI.parse(url)
response = Net::HTTP.get_response(uri)
if response.code.to_i != 200
puts "======= 接口请求失败!"
data = { data: nil, msg: '文件不存在' }
else
data = { data: JSON.parse(response.body), msg: 'ok' }
end
render_ok data
end
def measures_search_history
params_data = {
from: params[:form],

View File

@ -1,5 +1,4 @@
class Api::V1::UsersController < Api::V1::BaseController
include AesCryptHelper
before_action :load_observe_user, except: [:check_user_id, :check_user_login]
before_action :check_auth_for_observe_user, except: [:check_user_id, :check_user_login]
@ -54,7 +53,7 @@ class Api::V1::UsersController < Api::V1::BaseController
end
def check_password
password = decrypt(params[:password]) rescue params[:password].to_s
password = params[:password]
return tip_exception(-5, "8~16位密码支持字母数字和符号") unless password =~ CustomRegexp::PASSWORD
return tip_exception(-5, "密码错误") unless @observe_user.check_password?(password)
render_ok
@ -127,8 +126,7 @@ class Api::V1::UsersController < Api::V1::BaseController
def destroy
password = decrypt(params[:password]) rescue params[:password].to_s
return tip_exception(-1, "密码不正确.") unless @observe_user.check_password?(password)
return tip_exception(-1, "密码不正确.") unless @observe_user.check_password?(params[:password])
org_ids = TeamUser.where(user_id: @observe_user.id).pluck(:organization_id) | OrganizationUser.where(user_id: @observe_user.id).pluck(:organization_id)
org_count = TeamUser.where(organization_id: org_ids).where(user_id: @observe_user.id).joins(:team).where(teams: {authorize: %w(owner)}).count
project_count = Project.where(user_id: @observe_user.id).count

View File

@ -421,6 +421,24 @@ class ApplicationController < ActionController::Base
"#{edu_setting('git_address_domain')}/#{repo_path}"
end
# 通关后,把最后一次成功的代码存到数据库
# type 0 创始内容, 1 最新内容
# def game_passed_code(path, myshixun, game_id)
# # 如果代码窗口是隐藏的,则不用保存代码
# return if myshixun.shixun.hide_code || myshixun.shixun.vnc
# file_content = git_fle_content myshixun.repo_path, path
# #unless file_content.present?
# # raise("获取文件代码异常")
# #end
# logger.info("#######game_id:#{game_id}, file_content:#{file_content}")
# game_code = GameCode.where(:game_id => game_id, :path => path).first
# if game_code.nil?
# GameCode.create!(:game_id => game_id, :new_code => file_content, :path => path)
# else
# game_code.update_attributes!(:new_code => file_content)
# end
# end
# Post请求
def uri_post(uri, params)
begin
@ -512,6 +530,112 @@ class ApplicationController < ActionController::Base
end
# 实训主类别列表,自带描述
def shixun_main_type
list = []
mirrors = MirrorRepository.select([:id, :type_name, :description, :name]).published_main_mirror
mirrors.try(:each) do |mirror|
list << {id: mirror.id, type_name: mirror.type_name, description: mirror.try(:description), mirror_name: mirror.name}
end
list
end
# 小类别列表
def shixun_small_type
list = []
mirrors = MirrorRepository.select([:id, :type_name, :description, :name]).published_small_mirror
mirrors.try(:each) do |mirror|
list << {id: mirror.id, type_name: mirror.type_name, description: mirror.description, mirror_name: mirror.name}
end
list
end
def container_limit(mirror_repositories)
container = []
mirror_repositories.each do |mr|
if mr.name.present?
container << {:image => mr.name, :cpuLimit => mr.cpu_limit, :memoryLimit => "#{mr.memory_limit}M", :type => mr.try(:main_type) == "1" ? "main" : "sub"}
end
end
container.to_json
end
# 实训中间层pod配置
def shixun_container_limit shixun
container = []
shixun.shixun_service_configs.each do |config|
mirror = config.mirror_repository
if mirror.name.present?
# 资源限制没有就传默认值。
cpu_limit = config.cpu_limit.presence || 1
cpu_request = config.lower_cpu_limit.presence || 0.1
memory_limit = config.memory_limit.presence || 1024
request_limit = config.request_limit.presence || 10
resource_limit = config.resource_limit.presence || 10000
container << {:image => mirror.name,
:cpuLimit => cpu_limit,
:cpuRequest => cpu_request,
:memoryLimit => "#{memory_limit}M",
:memoryRequest => "#{request_limit}M",
:resourceLimit => "#{resource_limit}K",
:type => mirror.try(:main_type) == "1" ? "main" : "sub"}
end
end
container.to_json
end
# 毕设任务列表的赛选
def course_work(task, **option)
logger.info("#############{option}")
course = task.course
work_list = task.graduation_works.includes(user: [:user_extension])
# 教师评阅搜索 0: 未评, 1 已评
if option[:teacher_comment]
graduation_work_ids = GraduationWorkScore.where(graduation_work_id: work_list.map(&:id)).pluck(:graduation_work_id)
if option[:teacher_comment].zero?
work_list = work_list.where.not(id: graduation_work_ids)
elsif option[:teacher_comment] == 1
work_list = work_list.where(id: graduation_work_ids).where.not(work_status: 0)
end
end
# 作品状态 0 未提交, 1 按时提交, 2 延迟提交
if option[:task_status]
work_list = work_list.where(work_status: option[:task_status])
end
# 分班情况
if option[:course_group]
group_user_ids = course.course_members.where(course_group_id: option[:course_group]).pluck(:user_id)
# 有分组只可能是老师身份查看列表
work_list = work_list.where(user_id: group_user_ids)
end
# 只看我的交叉评阅
if option[:cross_comment]
graduation_work_id = task.graduation_work_comment_assignations.where(:user_id => current_user.id)
.pluck(:graduation_work_id).uniq if task.graduation_work_comment_assignations
work_list = work_list.where(id: graduation_work_id)
end
# 输入姓名和学号搜索
# TODO user_extension 如果修改 请调整
if option[:search]
work_list = work_list.joins(user: :user_extension).where("concat(lastname, firstname) like ?
or student_id like ?", "%#{option[:search]}%", "%#{option[:search]}%")
end
# 排序
rorder = UserExtension.column_names.include?(option[:order]) ? option[:order] : "updated_at"
b_order = %w(desc asc).include?(option[:b_order]) ? option[:b_order] : "desc"
if rorder == "created_at" || rorder == "work_score"
work_list = work_list.order("graduation_works.#{rorder} #{b_order}")
elsif rorder == "student_id"
work_list = work_list.joins(user: :user_extension).order("user_extensions.#{rorder} #{b_order}")
end
work_list
end
def strip_html(text, len=0, endss="...")
ss = ""
if !text.nil? && text.length>0
@ -1052,46 +1176,15 @@ class ApplicationController < ActionController::Base
# 接口限流,请求量大有性能问题
def request_limit
white_list_ip = ["106.75.110.152"]
unless white_list_ip.include?(request.remote_ip)
record_count = Rails.cache.read("request/#{controller_name}/#{Time.now.strftime('%Y%m%d%H')}/#{request.remote_ip}")
if record_count.present?
record_count = record_count + 1
else
record_count = 1
end
Rails.logger.info("请求太快,请稍后再试。#{controller_name}::#{request.remote_ip}") if record_count > 200
tip_exception("请求太快,请稍后再试。") if record_count > 200
Rails.cache.write("request/#{controller_name}/#{Time.now.strftime('%Y%m%d%H')}/#{request.remote_ip}", record_count, expires_in: 1.hour)
end
end
def check_batch_requests
check_key = "request.remote_ip:#{request.remote_ip}"
result = Rails.cache.read(check_key)
if result.present?
if result.to_i > 100
tip_exception(401, '暂时无法请求,请稍后再试')
else
Rails.cache.write(check_key, result.to_i + 1)
end
else
Rails.cache.write(check_key, 1, expires_in: 1.hour)
end
end
def request_raw_limit
record_count = Rails.cache.read("request/#{request.path}/#{Time.now.strftime('%Y%m%d%H')}}")
record_count = Rails.cache.read("request/#{controller_name}/#{Time.now.strftime('%Y%m%d%H%M')}/#{request.remote_ip}")
if record_count.present?
record_count = record_count + 1
else
record_count = 1
end
Rails.logger.info("请求太快,请稍后再试。#{request.path}") if record_count > 1000
tip_exception("请求太快,请稍后再试。") if record_count > 1000
tip_exception("请求太快,请稍后再试。") if record_count > 100
Rails.cache.write("request/#{request.path}/#{Time.now.strftime('%Y%m%d%H')}}", record_count, expires_in: 1.hour)
Rails.cache.write("request/#{controller_name}/#{Time.now.strftime('%Y%m%d%H%M')}/#{request.remote_ip}", record_count, expires_in: 1.minute)
end
end

View File

@ -19,10 +19,9 @@ class CommitLogsController < ApplicationController
params[:commits].each do |commit|
commit_id = commit[:id]
message = commit[:message]
commit_date = Time.parse(commit[:timestamp]) || Time.now
commit_log = CommitLog.create(user: user, project: project, repository_id: repository_id,
name: repository_name, full_name: repository_full_name,
ref: ref, commit_id: commit_id, message: message, created_at: commit_date, updated_at: commit_date)
ref: ref, commit_id: commit_id, message: message)
commit_log.project_trends.create(user_id: user.id, project_id: project&.id, action_type: "create") if user.id !=2
# 统计数据新增
CacheAsyncSetJob.perform_later("project_common_service", {commits: 1}, project.id)

View File

@ -3,7 +3,7 @@ module Api::PullHelper
def load_pull_request
pull_request_id = params[:pull_id] || params[:id]
@pull_request = @project.pull_requests.where(gitea_number: pull_request_id).where.not(id: pull_request_id).take || @project.pull_requests.find_by_id(pull_request_id)
@pull_request = @project.pull_requests.where(gitea_number: pull_request_id).where.not(id: pull_request_id).take || PullRequest.find_by_id(pull_request_id)
@issue = @pull_request&.issue
if @pull_request
logger.info "###########pull_request founded"

View File

@ -32,8 +32,18 @@ module LaboratoryHelper
end
def default_course_links
# my_projects: "/users/#{current_user.try(:login)}/projects",
# my_projects: "https://www.trustie.net/users/#{current_user.try(:login)}/user_projectlist",
{
default_url: Rails.application.config_for(:configuration)['platform_url']
new_syllabuses: "https://www.trustie.net/syllabuses/new",
new_course: "https://www.trustie.net/courses/new",
edit_account: "https://www.trustie.net/my/account",
my_courses: "https://www.trustie.net/users/#{current_user.try(:login)}/user_courselist",
my_projects: "/users/#{current_user.try(:login)}/projects",
my_organ: "https://www.trustie.net/users/#{current_user.try(:login)}/user_organizations",
default_url: Rails.application.config_for(:configuration)['platform_url'],
tiding_url: "https://www.trustie.net/users/#{current_user.try(:login)}/user_messages",
register_url: "https://www.trustie.net/login?login=false"
}
end
end

View File

@ -1,17 +0,0 @@
class HomeController < ApplicationController
def index
@user_count = Rails.cache.fetch("homecontroller:user_count", expires_in: 1.hours) do
User.count
end
@project_count = Rails.cache.fetch("homecontroller:project_count", expires_in: 1.hours) do
Project.count
end
@project_dataset_count = Rails.cache.fetch("homecontroller:project_dataset_count", expires_in: 1.hours) do
ProjectDataset.count
end
@commit_count = Rails.cache.fetch("homecontroller:commit_count", expires_in: 1.hours) do
CommitLog.count
end
end
end

View File

@ -4,8 +4,4 @@ class LicensesController < ApplicationController
q = License.ransack(name_cont: params[:name])
@licenses = q.result(distinct: true)
end
def show
@license = License.find(params[:id])
end
end

View File

@ -21,7 +21,6 @@ class MainController < ApplicationController
end
def index
Rails.logger.info("request.referer============#{request.referer},#{params[:path]}") if request.referer.to_s.include?("educoder.net")
domain_session = params[:_educoder_session]
if domain_session
uid_logger("main start domain_session is #{domain_session}")

View File

@ -45,9 +45,6 @@ class Oauth::EducoderController < Oauth::BaseController
result = EducoderOauth::Service.access_token(code)
result = EducoderOauth::Service.user_info(result[:access_token])
Rails.logger.info("OAuth2-session-unionid====111=======#{result['login']}")
tip_exception("调用头歌接口错误") if result['login'].blank?
# 存在该用户
open_user = OpenUsers::Educoder.find_by(uid: result['login'])
if open_user.present? && open_user.user.present?
@ -71,7 +68,7 @@ class Oauth::EducoderController < Oauth::BaseController
OpenUsers::Educoder.create!(user: current_user, uid: result['login'], extra: result)
end
end
Rails.logger.info("OAuth2-session-unionid=========== #{session[:unionid]}")
Rails.logger.info("[OAuth2] session[:unionid] -> #{session[:unionid]}")
redirect_to "/bindlogin/educoder"
# redirect_to root_path(new_user: new_user)

View File

@ -1,4 +1,4 @@
class Oauth2Controller < ApplicationController
class Oauth2Controller < ActionController::Base
layout 'doorkeeper/application'
include LoginHelper
@ -6,9 +6,6 @@ class Oauth2Controller < ApplicationController
client_id = params[:call_url].split("client_id=")[1].split("&redirect_uri")[0]
@call_url = request.fullpath.split('call_url=').last
@app = Doorkeeper::Application.find_by(uid: client_id)
if User.current.logged?
redirect_to @call_url + "&auth=" + User.current.login
end
end
def create

View File

@ -1,5 +1,4 @@
class Organizations::OrganizationsController < Organizations::BaseController
include AesCryptHelper
before_action :require_login, except: [:index, :show, :recommend, :languages]
# before_action :require_profile_completed, only: [:create]
before_action :convert_image!, only: [:create, :update]
@ -140,7 +139,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
end
def password
decrypt(params[:password]) rescue params[:password].to_s
params.fetch(:password, "")
end
def load_organization

View File

@ -12,7 +12,7 @@ class Organizations::ProjectsController < Organizations::BaseController
keywords = params[:search].to_s.each_char.select { |c| c.bytes.first < 240 }.join('')
@projects = @projects.where(id: params[:pm_project_repository_ids].split(',')) if params[:pm_project_repository_ids].present?
@projects = @projects.where.not(id: params[:exclude_ids].to_s.split(",")) if params[:exclude_ids].present?
@projects = @projects.where(project_type: ['mirror', 'common']).where("gpid is not null") if params[:actived].present?
@projects = @projects.where("gpid is not null") if params[:actived].present?
@projects = @projects.ransack(name_or_identifier_cont: keywords).result if params[:search].present?
@projects = @projects.includes(:owner).order("projects.#{sort} #{sort_direction}")
@projects = paginate(@projects)

View File

@ -253,7 +253,6 @@ class PullRequestsController < ApplicationController
normal_status(-1, result.message)
end
rescue => e
logger_error(e)
normal_status(-1, e.message)
raise ActiveRecord::Rollback
end

View File

@ -14,8 +14,6 @@ class RepositoriesController < ApplicationController
before_action :get_latest_commit, only: %i[entries sub_entries top_counts]
before_action :get_statistics, only: %i[top_counts]
before_action :require_referer, only: [:raw]
# before_action :request_limit, only: [:raw]
before_action :request_raw_limit, only: [:raw]
def files
result = @project.educoder? ? nil : Gitea::Repository::Files::GetService.call(@owner, @project.identifier, @ref, params[:search], @owner.gitea_token)
@ -37,10 +35,6 @@ class RepositoriesController < ApplicationController
@fork_project = Project.find_by(id: @project_fork_id)
@fork_project_user = @fork_project.owner
end
# 修正默认分支
if @result[:repo].present? && @result[:repo]['default_branch'].present? && @result[:repo]['default_branch'] != @project.default_branch
@project.update_column('default_branch', @result[:repo]['default_branch'])
end
rescue Exception => e
uid_logger_error(e.message)
tip_exception(e.message)
@ -304,7 +298,7 @@ class RepositoriesController < ApplicationController
redirect_to file_path
end
def raw
def raw
domain = GiteaService.gitea_config[:domain]
api_url = GiteaService.gitea_config[:base_url]

View File

@ -1,12 +1,13 @@
class SettingsController < ApplicationController
def show
@old_projects_url = nil
get_navbar
site_page_deploy_domain
get_add_menu
get_common_menu
get_sub_competitions
get_personal_menu
# get_third_party
get_third_party
get_third_party_new
get_top_system_notification
end

View File

@ -54,9 +54,9 @@ class SitePagesController < ApplicationController
user = User.find_by_login params[:repository][:owner][:login]
return normal_status(-1, '你还未开通Page服务无法进行部署') unless user.website_permission
project = Project.find_by(identifier: params[:repository][:name],user_id: user.id)
return normal_status(-1, '项目不存在') if project.nil?
return normal_status(-1, '该仓库还未开通Page服务无法进行部署') unless Page.exists?(user: user, project: project)
project = Project.where(identifier: params[:repository][:name],user_id: user.id)
return normal_status(-1, '你没有权限操作') if project.owner?(user)
return normal_status(-1, '该仓库还未开通Page服务无法进行部署') if Page.exists?(user: user, project: project)
@page = Page.find_by(user: user, project: project)
response_str = @page.deploy_page(branch)

View File

@ -10,8 +10,6 @@ class Users::MessagesController < Users::BaseController
result = Notice::Read::ListService.call(observed_user.id, message_type, message_status, page, limit)
return render_error if result.nil?
@data = result[2]
rescue
render_ok
end
def create

View File

@ -263,7 +263,7 @@ class UsersController < ApplicationController
begin
@user = current_user
begin
result = EduSetting.get("notice_disable").to_s == "true" ? nil : Notice::Read::CountService.call(current_user.id)
result = Notice::Read::CountService.call(current_user.id)
@message_unread_total = result.nil? ? 0 : result[2]["unread_notification"]
rescue
@message_unread_total = 0

View File

@ -168,6 +168,7 @@ class VersionReleasesController < ApplicationController
attachment.container = target
attachment.author_id = current_user.id
attachment.description = ""
attachment.uuid = SecureRandom.uuid
attachment.save
end
end

View File

@ -1,6 +1,5 @@
class BaseForm
include ActiveModel::Model
include AesCryptHelper
Error = Class.new(StandardError)
EmailError = Class.new(Error)
@ -54,15 +53,11 @@ class BaseForm
end
def check_password(password)
password = decrypt(password) rescue password
password = strip(password)
raise PasswordFormatError, "密码8~16位密码支持字母数字和符号" unless password =~ CustomRegexp::PASSWORD
end
def check_password_confirmation(password, password_confirmation)
password = decrypt(password) rescue password
password_confirmation = decrypt(password_confirmation) rescue password_confirmation
password = strip(password)
password_confirmation = strip(password_confirmation)

View File

@ -9,7 +9,7 @@ module Register
login_exist = Owner.exists?(login: login) || ReversedKeyword.check_exists?(login)
if user.present?
raise LoginError, '登录名已被他人使用' if login_exist && login != user&.login
raise LoginError, '登录名已被使用' if login_exist && login != user&.login
else
raise LoginError, '登录名已被使用' if login_exist
end

View File

@ -8,7 +8,7 @@ module Register
def check!
user = User.find_by(id: user_id)
Rails.logger.info "Register::RemoteForm params: id: #{user_id}; username: #{username}; email: #{email}; password: #{password}; platform: #{platform}"
Rails.logger.info "Register::RemoteForm params: id: #{user&.id}; username: #{username}; email: #{email}; password: #{password}; platform: #{platform}"
check_login(username, user)
check_mail(email,user)
check_password(password)

View File

@ -1,45 +0,0 @@
module AesCryptHelper
AES_KEY = EduSetting.get("login_crypt_key") || '59c96c3572ab8cc1'
def encrypt(plain_text, output_encoding = 'base64')
# 将字符串密钥和IV转换为16字节的字节数组
key = AES_KEY.byteslice(0, 16)
iv = AES_KEY.byteslice(0, 16)
# 创建并设置AES-CBC加密器
cipher = OpenSSL::Cipher.new('AES-128-CBC')
cipher.encrypt
cipher.key = key
cipher.iv = iv
# 加密数据并添加PKCS7填充
encrypted_data = cipher.update(plain_text) + cipher.final
# 将加密数据转换为Base64编码
Base64.strict_encode64(encrypted_data)
end
def decrypt(cipher_text, input_encoding = 'base64')
# 确保密钥是16字节长
key = AES_KEY.byteslice(0, 16) # 如果密钥不足16字节填充空格如果超过截断
iv = AES_KEY.byteslice(0, 16)
decipher = OpenSSL::Cipher.new('AES-128-CBC')
decipher.decrypt
decipher.key = key
decipher.iv = iv
# 根据输入编码解码密文
decrypted_data = case input_encoding
when 'base64'
Base64.strict_decode64(cipher_text)
else
cipher_text
end
decrypted = decipher.update(decrypted_data) + decipher.final
decrypted
end
end

View File

@ -145,17 +145,17 @@ module ProjectsHelper
url = EduSetting.get("ai_shang_url") || "https://shang.gitlink.org.cn"
case project.identifier.to_s.downcase
when nil then ""
# when 'rails' then "#{url}/v1/rails/entropy"
# when 'jittor' then "#{url}/v1/jittor/entropy"
# when 'paddle' then "#{url}/v1/Paddle/entropy"
# when 'vue' then "#{url}/v1/vue/entropy"
# when 'bootstrap' then "#{url}/v1/bootstrap/entropy"
# when 'tensorflow' then "#{url}/v1/tensorflow/entropy"
# when 'kernel' then "#{url}/v1/openeuler/entropy"
# when 'opengauss-server' then "#{url}/v1/opengauss/entropy"
# when 'mindspore' then "#{url}/v1/mindspore/entropy"
when 'openharmony-kernel' then "#{url}/api/openharmony/entropy"
when 'kernel' then "#{url}/api/openeuler/entropy"
when 'rails' then "#{url}/v1/rails/entropy"
when 'jittor' then "#{url}/v1/jittor/entropy"
when 'paddle' then "#{url}/v1/Paddle/entropy"
when 'vue' then "#{url}/v1/vue/entropy"
when 'bootstrap' then "#{url}/v1/bootstrap/entropy"
when 'tensorflow' then "#{url}/v1/tensorflow/entropy"
when 'kernel' then "#{url}/v1/openeuler/entropy"
when 'opengauss-server' then "#{url}/v1/opengauss/entropy"
when 'mindspore' then "#{url}/v1/mindspore/entropy"
when 'openharmony' then "#{url}/api/openharmony/entropy"
when 'openeuler' then "#{url}/api/openeuler/entropy"
when 'xiuos' then "#{url}/api/xiuos/entropy"
else ''
end

View File

@ -161,7 +161,6 @@ module RepositoriesHelper
s_content = s_content.starts_with?("/") ? s_content[1..-1] : s_content[0..-1]
s_content = File.expand_path(s_content, file_path)
s_content = s_content.split("#{Rails.root}/")[1]
next if s_content.blank?
# content = content.gsub(s[0], "/#{s_content}")
join_xxx = s_content.include?("?") ? "&" : "?"
s_content = [base_url, "/api/#{owner&.login}/#{repo.identifier}/raw/#{s_content}#{join_xxx}ref=#{ref}"].join
@ -191,7 +190,6 @@ module RepositoriesHelper
path = [owner&.login, repo&.identifier, 'tree', ref, file_path].join("/")
s_content = File.expand_path(s_content, path)
s_content = s_content.split("#{Rails.root}")[1]
next if s_content.blank?
case k.to_s
when 'ss_src'
content = content.gsub("src=\"#{s[0]}\"", "src=\"/#{s_content}\"")
@ -204,7 +202,7 @@ module RepositoriesHelper
when 'ss_href_1'
content = content.gsub("href=\'#{s[0]}\'", "href=\'#{s_content}\'")
else
content = content.gsub("(#{s[0]})", "(#{s_content})")
content = content.gsub("(#{s[0]})", "(/#{s_content})")
end
end
rescue

View File

@ -9,16 +9,17 @@ class ChangeIssueStatusByMessageJob < ApplicationJob
def get_pm_issue_data(user, org, pm_project_id, issue_id)
url = "#{EduSetting.get("pms_server_url")}/api/pms/#{org.login}/pmsProjectIssues/#{issue_id}?pmProjectId=#{pm_project_id}"
url = URI("#{EduSetting.get("pms_server_url")}/api/pms/#{org.login}/pmsProjectIssues/#{issue_id}?pmProjectId=#{pm_project_id}")
headers = {
'Cookie' => "autologin_trustie=#{Token.get_or_create_permanent_login_token(user, 'autologin')&.value}",
}
response = RestClient.get(url, headers)
puts response.body
return JSON.parse(response.body)["code"].to_i == 200
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Cookie"] = "autologin_trustie=#{Token.get_or_create_permanent_login_token(user, 'autologin')&.value}"
response = https.request(request)
puts response.read_body
return JSON.parse(response.read_body)['code'].to_i == 200
rescue
return false
end
@ -32,7 +33,6 @@ class ChangeIssueStatusByMessageJob < ApplicationJob
issue = project.issues.issue_issue.where(project_issues_index: issue_id).where.not(id: issue_id).take || Issue.issue_issue.find_by_id(issue_id)
next unless issue.present? # issue不存在 跳过
next if issue.project.present? && !issue.project.member?(user) # issue归属项目用户没有修改issue的权限跳过
next if issue.pm_project_id.nil? && project.id.to_i != issue.project&.id.to_i
next if issue.pm_project_id.present? && !get_pm_issue_data(user, project.owner, issue.pm_project_id, issue.id) # issue是组织下工作项不具备组织的访问权限跳过
issue_project = issue.project || Project.new(id: 0, user_id: 0, name: 'pm_mm', identifier: 'pm_mm', is_public:true)

View File

@ -8,8 +8,7 @@ class TouchWebhookJob < ApplicationJob
issue = Issue.find_by_id issue_id
sender = User.find_by_id sender_id
return if issue.nil? || sender.nil?
return if issue.project.nil?
issue.project.webhooks.each do |webhook|
issue.project.webhooks.each do |webhook|
next unless webhook.events["events"]["issues"]
_, _, @webhook_task = Webhook::IssueClient.new(webhook, issue, sender,"issues").do_request
Rails.logger.info "Touch Webhook Response result: #{@webhook_task.response_content}"
@ -19,7 +18,6 @@ class TouchWebhookJob < ApplicationJob
issue = Issue.find_by_id issue_id
sender = User.find_by_id sender_id
return if issue.nil? || sender.nil? || !changes.is_a?(Hash) || changes.blank?
return if issue.project.nil?
issue.project.webhooks.each do |webhook|
next unless webhook.events["events"]["issues"]
_, _, @webhook_task = Webhook::IssueClient.new(webhook, issue, sender, "issues", changes.stringify_keys).do_request
@ -31,7 +29,6 @@ class TouchWebhookJob < ApplicationJob
issue = Issue.find_by_id issue_id
sender = User.find_by_id sender_id
return if issue.nil? || sender.nil?
return if issue.project.nil?
issue.project.webhooks.each do |webhook|
next unless webhook.events["events"]["issue_assign"]
_, _, @webhook_task = Webhook::IssueClient.new(webhook, issue, sender, "issue_assign", changes.stringify_keys).do_request
@ -42,8 +39,7 @@ class TouchWebhookJob < ApplicationJob
issue_id, sender_id, changes = args[0], args[1], args[2]
issue = Issue.find_by_id issue_id
sender = User.find_by_id sender_id
return if issue.nil? || sender.nil?
return if issue.project.nil?
return if issue.nil? || sender.nil?
issue.project.webhooks.each do |webhook|
next unless webhook.events["events"]["issue_label"]
_, _, @webhook_task = Webhook::IssueClient.new(webhook, issue, sender, "issue_label", changes.stringify_keys).do_request
@ -57,7 +53,6 @@ class TouchWebhookJob < ApplicationJob
return if issue.nil? || sender.nil?
comment = issue.comment_journals.find_by_id comment_id
return if action_type == 'edited' && comment_json.blank?
return if issue.project.nil?
issue.project.webhooks.each do |webhook|
next unless webhook.events["events"]["issue_comment"]
@ -73,7 +68,6 @@ class TouchWebhookJob < ApplicationJob
return if issue.nil? || pull.nil? || sender.nil?
comment = issue.comment_journals.find_by_id comment_id
return if action_type == 'edited' && comment_json.blank?
return if issue.project.nil?
pull.project.webhooks.each do |webhook|
next unless webhook.events["events"]["pull_request_comment"]

View File

@ -7,7 +7,7 @@ module EducoderOauth::Service
begin
Rails.logger.info("[EducoderOauth] [#{method.to_s.upcase}] #{url} || #{params}")
client = Faraday.new(url: EducoderOauth.base_url, headers: {'X-EDU-Timestamp' => "#{Time.now.to_i}"})
client = Faraday.new(url: EducoderOauth.base_url)
response = client.public_send(method, url, params)
result = JSON.parse(response.body)

View File

@ -1,44 +0,0 @@
module SonarService
def build_sonar_content(owner,project_id,lang_keys)
lang_map = {
'Java' => :java,
'Python' => :python,
'JavaScript' => :js,
'TypeScript' => :ts,
'C++' => :cpp,
'C' => :cpp
}
detected_langs = lang_keys.map { |l| lang_map[l] }.compact.to_set
lines = []
lines << "sonar.projectKey=#{owner}-#{project_id}"
lines << "sonar.projectVersion=1.0"
lines << "sonar.sourceEncoding=UTF-8"
lines << "sonar.sources=."
lines << "sonar.exclusions=**/test/**,**/tests/**,**/vendor/**,**/node_modules/**,**/__pycache__/**"
if detected_langs.include?(:java)
lines << "sonar.java.binaries="
end
if detected_langs.include?(:js)
lines << "sonar.javascript.lcov.reportPaths=coverage/lcov.info"
end
if detected_langs.include?(:ts)
lines << "sonar.typescript.tsconfigPath=tsconfig.json"
end
if detected_langs.include?(:python)
lines << "sonar.python.coverage.reportPaths=coverage.xml"
end
if detected_langs.include?(:cpp)
lines << "sonar.cxx.file.suffixes=.cpp,.c,.cc,.h,.hpp,.hh"
lines << "sonar.cxx.errorRecoveryEnabled=true"
end
lines.join("\n")
end
end

View File

@ -17,15 +17,11 @@
# created_at :datetime not null
# updated_at :datetime not null
# label :string(255)
# node_type :string(255)
# is_mutil_link :boolean
# link_type :string(255)
#
# Indexes
#
# by_name (name)
# index_action_nodes_on_action_types_id (action_node_types_id)
# index_action_nodes_on_user_id (user_id)
# index_action_nodes_on_action_node_types_id (action_node_types_id)
# index_action_nodes_on_user_id (user_id)
#
class Action::Node < ApplicationRecord
@ -38,7 +34,7 @@ class Action::Node < ApplicationRecord
belongs_to :user, optional: true
attr_accessor :cust_name, :run_values, :input_values, :parent_node_id, :sub_nodes, :link_type_array, :node_id
attr_accessor :cust_name, :run_values, :input_values
validates :name, presence: { message: "不能为空" }
validates :full_name, length: { maximum: 200, too_long: "不能超过200个字符" }
@ -46,7 +42,6 @@ class Action::Node < ApplicationRecord
validates :description, length: { maximum: 65535, too_long: "不能超过65535个字符"}
def content_yaml
"foo".to_yaml
<<~YAML

View File

@ -33,7 +33,7 @@ class Action::Pipeline < ApplicationRecord
belongs_to :user, optional: true
belongs_to :project
validates :pipeline_name, presence: { message: "不能为空" }
validates :name, presence: { message: "不能为空" }
validates :json, length: { maximum: 65535, too_long: "不能超过65535个字符"}
validates :yaml, length: { maximum: 65535, too_long: "不能超过65535个字符"}
end

View File

@ -1,25 +0,0 @@
# == Schema Information
#
# Table name: action_pipeline_results
#
# id :integer not null, primary key
# project_id :integer
# run_id :integer
# step_id :string(255)
# job_name :string(255)
# job_show_type :string(255)
# job_result :text(65535)
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_action_pipeline_results_on_project_id (project_id)
# index_action_pipeline_results_on_run_id (run_id)
#
class Action::PipelineResult < ApplicationRecord
self.table_name = 'action_pipeline_results'
belongs_to :project
end

View File

@ -24,7 +24,7 @@
class CommitLog < ApplicationRecord
belongs_to :user
belongs_to :project
# belongs_to :repository
belongs_to :repository
has_many :project_trends, as: :trend, dependent: :destroy

View File

@ -1,23 +1,22 @@
# == Schema Information
#
# Table name: edu_settings
#
# id :integer not null, primary key
# name :string(255)
# value :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# description :string(255)
#
# Indexes
#
# index_edu_settings_on_name (name) UNIQUE
#
# == Schema Information
#
# Table name: edu_settings
#
# id :integer not null, primary key
# name :string(255)
# value :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# description :string(255)
#
# Indexes
#
# index_edu_settings_on_name (name) UNIQUE
#
class EduSetting < ApplicationRecord
after_commit :expire_value_cache, on: [:create, :update]
after_commit :clear_value_cache, on: :destroy
after_commit :expire_value_cache
scope :by_search, -> (keyword){ where("name LIKE :keyword OR value LIKE :keyword", keyword: "%#{strip_param(keyword)}%") unless strip_param(keyword).blank? }
@ -26,11 +25,7 @@ class EduSetting < ApplicationRecord
end
def self.get(key)
begin
Rails.cache.fetch(value_cache_key(key), expires_in: 1.days) do
find_by_name(key.to_s)&.value
end
rescue Exception => e
Rails.cache.fetch(value_cache_key(key), expires_in: 1.days) do
find_by_name(key.to_s)&.value
end
end
@ -46,8 +41,4 @@ class EduSetting < ApplicationRecord
def expire_value_cache
Rails.cache.write(value_cache_key, value)
end
def clear_value_cache
Rails.cache.delete(value_cache_key)
end
end

View File

@ -1,9 +0,0 @@
class Gitea::ActionRun < Gitea::Base
self.inheritance_column = nil # FIX The single-table inheritance mechanism failed
# establish_connection :gitea_db
self.table_name = "action_run"
# belongs_to :user, class_name: '::User', primary_key: :gitea_uid, foreign_key: :owner_id, optional: true
end

View File

@ -1,9 +0,0 @@
class Gitea::RepoUnit < Gitea::Base
self.inheritance_column = nil # FIX The single-table inheritance mechanism failed
# establish_connection :gitea_db
self.table_name = "repo_unit"
# belongs_to :user, class_name: '::User', primary_key: :gitea_uid, foreign_key: :owner_id, optional: true
end

View File

@ -26,7 +26,7 @@ class IdentityVerification < ApplicationRecord
after_create do
Attachment.where(uuid:[card_front,card_back,hold_card_front,hold_card_back]).update_all(is_public:0)
end
after_save do
if state == "已通过"
user.update(id_card_verify: true, website_permission: true)

View File

@ -102,7 +102,6 @@ class Issue < ApplicationRecord
scope :issue_issue, ->{where(issue_classify: [nil, 'issue'])}
scope :issue_pull_request, ->{where(issue_classify: 'pull_request')}
scope :issue_index_includes, ->{includes(:tracker, :priority, :version, :issue_status, :journals,:issue_tags,user: :user_extension)}
scope :pm_includes, -> {includes(:project, :show_issue_tags, :issue_status, :priority, :version, :user, :show_assigners, :comment_journals, :operate_journals)}
scope :closed, ->{where(status_id: 5)}
scope :opened, ->{where.not(status_id: 5)}
after_create :incre_project_common, :incre_user_statistic, :incre_platform_statistic
@ -298,38 +297,6 @@ class Issue < ApplicationRecord
self.project.decrement!(:closed_issues_count) if self.status_id == 5 && self.project.present?
end
# def self.find_issues_by_pm(enterprise_identifier, pm_issue_type)
# case pm_issue_type.to_i
# when 1
# Issue.issue_issue.where(enterprise_identifier: enterprise_identifier)
# .where(pm_issue_type: pm_issue_type)
# .where(pm_issue_type_index1: index)
# when 2
# Issue.issue_issue.where(enterprise_identifier: enterprise_identifier)
# .where(pm_issue_type: pm_issue_type)
# .where(pm_issue_type_index2: index)
# when 3
# Issue.issue_issue.where(enterprise_identifier: enterprise_identifier)
# .where(pm_issue_type: pm_issue_type)
# .where(pm_issue_type_index3: index)
# end
# end
#
# def self.build_pm_index(enterprise_identifier, pm_issue_type)
# last_issue = Issue.find_issues_by_pm(enterprise_identifier, pm_issue_type).order("pm_issue_type_index#{pm_issue_type.to_i} asc").last
# deleted_issue_count = ($redis_cache.hget("pm_issue_cache_delete_count", enterprise_identifier) || 0).to_i
#
# last_issue.send("pm_issue_type_index#{pm_issue_type.to_i}").present? ? last_issue.send("pm_issue_type_index#{pm_issue_type.to_i}") + deleted_issue_count : 0
# end
#
# def incre_pm_issue_cache_delete_count(count=1)
# $redis_cache.hincrby("pm_issue_cache_delete_count", self.enterprise_identifier, count)
# end
#
# def del_pm_issue_cache_delete_count
# $redis_cache.hdel("pm_issue_cache_delete_count", self.enterprise_identifier)
# end
def send_update_message_to_notice_system
SendTemplateMessageJob.perform_later('IssueExpire', self.id) if Site.has_notice_menu? && self.due_date == Date.today + 1.days
end
@ -356,7 +323,7 @@ class Issue < ApplicationRecord
end
end
def to_builder
def to_builder
Jbuilder.new do |issue|
issue.(self, :id, :project_issues_index, :subject, :description, :branch_name, :start_date, :due_date)
issue.created_at self.created_on.strftime('%Y-%m-%d %H:%M')

View File

@ -52,7 +52,6 @@ class Journal < ApplicationRecord
scope :journal_includes, ->{includes(:user, :journal_details, :attachments)}
scope :parent_journals, ->{where(parent_id: nil)}
scope :children_journals, lambda{|journal_id| where(parent_id: journal_id)}
scope :operate_journals, ->{where(notes: nil)}
enum state: {opened: 0, resolved: 1, disabled: 2}
@ -104,21 +103,6 @@ class Journal < ApplicationRecord
end
end
def pm_dashboard_operate_content
content = self.pm_operate_content
if content.start_with?('创建了')
content += "<b>#{self.issue.subject}</b>"
else
prefix = '将'
prefix += "计划" if self.issue.pm_issue_type == 1
prefix += "任务" if self.issue.pm_issue_type == 2
prefix += "缺陷" if self.issue.pm_issue_type == 3
prefix += "<b>#{self.issue.subject}</b>"
content = prefix + content.sub('将', '的')
end
content
end
def pm_operate_content
content = "#{operate_by_content}"
detail = self.journal_details.take

View File

@ -453,7 +453,7 @@ class Project < ApplicationRecord
end
def get_last_project_issues_index
last_issue = self.issues.issue_issue.order(project_issues_index: :asc).last
last_issue = self.issues.issue_issue.last
deleted_issue_count = ($redis_cache.hget("issue_cache_delete_count", self.id) || 0).to_i
last_issue&.project_issues_index.present? ? last_issue.project_issues_index + deleted_issue_count : 0

View File

@ -23,7 +23,7 @@ class ProjectUnit < ApplicationRecord
def self.init_types(project_id, project_type='common')
unit_types = project_type == 'sync_mirror' ? ProjectUnit::unit_types.except("pulls") : ProjectUnit::unit_types
unit_types = unit_types.except("dataset") unless EduSetting.get("is_local") == "true"
unit_types = unit_types.except("dataset")
unit_types.each do |_, v|
self.create!(project_id: project_id, unit_type: v)
end

View File

@ -692,11 +692,7 @@ class User < Owner
# Returns the user who matches the given autologin +key+ or nil
def self.try_to_autologin(key)
user = Token.find_active_user('autologin', key)
if user
Rails.cache.fetch("user::update::last_login_on::#{user.id}",:expires_in => 5.minutes) do
user.update(last_login_on: Time.now)
end
end
user.update(last_login_on: Time.now) if user
user
end

View File

@ -20,8 +20,7 @@ class Projects::ListMyQuery < ApplicationQuery
if params[:category].blank?
normal_projects = projects.members_projects(user.id).to_sql
org_projects = projects.joins(team_projects: [team: :team_users]).where(team_users: {user_id: user.id}).to_sql
watched_projects = projects.where.not(user_id: user.id).joins(:watchers).where(watchers: {watchable_type: "Project", user_id: user.id}).to_sql
projects = Project.from("( #{ normal_projects} UNION #{ org_projects } UNION #{ watched_projects } ) AS projects")#.distinct
projects = Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects")#.distinct
elsif params[:category].to_s == "join"
normal_projects = projects.where.not(user_id: user.id).members_projects(user.id).to_sql
org_projects = projects.joins(team_projects: [team: :team_users]).where(team_users: {user_id: user.id}).to_sql

View File

@ -1,11 +1,10 @@
module Accounts
class ResetPasswordService < ApplicationService
include AesCryptHelper
# login、code、password、password_confirmation
def initialize(user, params)
@user = user
@password = decrypt(params[:password]) rescue params[:password].to_s
@password_confirmation = decrypt(params[:password_confirmation]) rescue params[:password_confirmation].to_s
@password = params[:password]
@password_confirmation = params[:password_confirmation]
end
def call

View File

@ -5,7 +5,7 @@ class Api::Pm::Issues::CreateService < ApplicationService
attr_reader :project, :current_user
attr_reader :status_id, :priority_id, :milestone_id, :branch_name, :start_date, :due_date, :subject, :description, :blockchain_token_num, :root_subject
attr_reader :issue_tag_ids, :assigner_ids, :attachment_ids, :receivers_login, :enterprise_identifier, :pm_issue_type
attr_reader :issue_tag_ids, :assigner_ids, :attachment_ids, :receivers_login
attr_accessor :created_issue
validates :subject, presence: true
@ -36,7 +36,6 @@ class Api::Pm::Issues::CreateService < ApplicationService
@time_scale = params[:time_scale]
@linkable_id = params[:link_able_id]
@root_subject = params[:root_subject]
@enterprise_identifier = params[:enterprise_identifier]
end
def call
@ -57,10 +56,10 @@ class Api::Pm::Issues::CreateService < ApplicationService
try_lock("Api::Pm::Issues::CreateService:#{project.id}") # 开始写数据,加锁
@created_issue = Issue.new(issue_attributes)
@created_issue.pm_issue_type = @pm_issue_type
if @root_subject.present? && [4, 5].include?(@pm_issue_type.to_i)
@root_issue = Issue.find_by(subject: @root_subject, pm_issue_type: [4,5], pm_project_id: @pm_project_id,enterprise_identifier: @enterprise_identifier)
if @root_subject.present? && @pm_issue_type.to_i == 4
@root_issue = Issue.find_by(subject: @root_subject, pm_issue_type: 4, pm_project_id: @pm_project_id)
unless @root_issue.present?
@root_issue = Issue.create(subject: @root_subject, pm_issue_type: @pm_issue_type.to_i, pm_project_id: @pm_project_id, enterprise_identifier: @enterprise_identifier, status_id: 1, priority_id: 1, tracker_id: Tracker.first.id, project_id: @project.id, author_id: current_user.id)
@root_issue = Issue.create(subject: @root_subject, pm_issue_type: 4, pm_project_id: @pm_project_id, status_id: 1, priority_id: 1, tracker_id: Tracker.first.id, project_id: @project.id, author_id: current_user.id)
end
@created_issue.root_id = @root_issue.id
else
@ -75,7 +74,6 @@ class Api::Pm::Issues::CreateService < ApplicationService
@created_issue.attachments = @attachments unless attachment_ids.blank?
@created_issue.issue_tags = @issue_tags unless issue_tag_ids.blank?
@created_issue.pm_project_id = @pm_project_id
@created_issue.enterprise_identifier = @enterprise_identifier
@created_issue.pm_sprint_id = @pm_sprint_id
@created_issue.time_scale = @time_scale
@created_issue.issue_tags_value = @issue_tags.order('id asc').pluck(:id).join(',') unless issue_tag_ids.blank?

View File

@ -4,7 +4,7 @@ class Api::Pm::Issues::UpdateService < ApplicationService
include Api::V1::Issues::Concerns::Loadable
attr_reader :project, :issue, :current_user, :operate_by
attr_reader :status_id, :priority_id, :milestone_id, :branch_name, :start_date, :due_date, :subject, :description, :blockchain_token_num,:status_msg
attr_reader :status_id, :priority_id, :milestone_id, :branch_name, :start_date, :due_date, :subject, :description, :blockchain_token_num
attr_reader :target_pm_project_id, :pm_sprint_id, :pm_issue_type, :root_id, :time_scale
attr_reader :issue_tag_ids, :assigner_ids, :attachment_ids, :receivers_login, :before_issue_tag_ids, :before_assigner_ids, :project_id
attr_accessor :add_assigner_ids, :previous_issue_changes, :updated_issue, :atme_receivers
@ -18,7 +18,6 @@ class Api::Pm::Issues::UpdateService < ApplicationService
@current_user = current_user
@operate_by = operate_by
@status_id = params[:status_id]
@status_msg = params[:status_msg]
@priority_id = params[:priority_id]
@milestone_id = params[:milestone_id]
@branch_name = params[:branch_name]
@ -86,10 +85,6 @@ class Api::Pm::Issues::UpdateService < ApplicationService
@updated_issue.root_id = @root_id unless @root_id.nil? #不为 nil的时候更新
@updated_issue.root_id = nil if @root_id.try(:zero?) #为 0 的时候设置为 nil
@updated_issue.time_scale = @time_scale unless @time_scale.nil?
if @project_id.present? && @updated_issue.project_id.to_i == 0
add_project = Project.find_by(id: @project_id)
@updated_issue.project_issues_index = add_project.get_last_project_issues_index + 1 if add_project.present?
end
@updated_issue.project_id = @project_id unless @project_id.nil?
@updated_issue.updated_on = Time.now
@updated_issue.changer_id = @current_user.id
@ -202,12 +197,7 @@ class Api::Pm::Issues::UpdateService < ApplicationService
# 修改状态
if @updated_issue.previous_changes["status_id"].present?
journal = @updated_issue.journals.create!({user_id: current_user.id, operate_by: @operate_by})
journal.journal_details.create!({property: @updated_issue.pm_issue_type_string,
prop_key: "status_id",
status_msg: @status_msg,
old_value: @updated_issue.previous_changes["status_id"][0],
value: @updated_issue.previous_changes["status_id"][1]}
)
journal.journal_details.create!({property: @updated_issue.pm_issue_type_string, prop_key: "status_id", old_value: @updated_issue.previous_changes["status_id"][0], value: @updated_issue.previous_changes["status_id"][1]})
end
# 修改优先级

View File

@ -3,7 +3,7 @@ class Api::V1::Issues::ListService < ApplicationService
attr_reader :project, :only_name, :category, :participant_category, :keyword, :author_id, :issue_tag_ids
attr_reader :begin_date, :end_date, :update_begin_date, :update_end_date
attr_reader :milestone_id, :assigner_id, :status_id, :priority_id, :sort_by, :sort_direction, :current_user, :enterprise_identifier
attr_reader :milestone_id, :assigner_id, :status_id, :priority_id, :sort_by, :sort_direction, :current_user
attr_reader :pm_project_id, :pm_project_ids, :pm_sprint_id, :root_id, :pm_issue_type, :status_ids, :ids, :exclude_ids, :pm_issue_types
attr_accessor :queried_issues, :total_issues_count, :closed_issues_count, :opened_issues_count, :complete_issues_count, :participator
@ -30,7 +30,6 @@ class Api::V1::Issues::ListService < ApplicationService
@update_begin_date = params[:update_begin_date]
@update_end_date = params[:update_end_date]
@sort_by = params[:sort_by].present? ? params[:sort_by] : 'issues.updated_on'
@enterprise_identifier = params[:enterprise_identifier]
@pm_project_id = params[:pm_project_id]
@pm_project_ids = params[:pm_project_ids]
@pm_sprint_id = params[:pm_sprint_id]
@ -46,7 +45,7 @@ class Api::V1::Issues::ListService < ApplicationService
end
def call
raise Error, errors.full_messages.join(', ') unless valid?
raise Error, errors.full_messages.join(', ') unless valid?
# begin
issue_query_data
@ -97,8 +96,6 @@ class Api::V1::Issues::ListService < ApplicationService
end
end
issues = issues.where(enterprise_identifier: enterprise_identifier) if enterprise_identifier.present? && ([4,5].include?(pm_issue_type.to_i) || pm_issue_types.present?)
#pm相关
# root_id# -1 查一级目录
issues = if root_id.to_i == -1
@ -151,7 +148,7 @@ class Api::V1::Issues::ListService < ApplicationService
end
if update_begin_date&.present? || update_end_date&.present?
issues = issues.where('issues.updated_on between ? and ?', update_begin_date&.present? ? update_begin_date.to_time.beginning_of_week : Time.now.beginning_of_week, update_end_date&.present? ? update_end_date.to_time.end_of_week : Time.now.end_of_week)
issues = issues.where('issues.updated_on between ? and ?', update_begin_date&.present? ? update_begin_date.to_time : Time.now.beginning_of_day, update_end_date&.present? ? update_end_date.to_time.end_of_day : Time.now.end_of_day)
end
# keyword

View File

@ -85,14 +85,9 @@ class Api::V1::Issues::UpdateService < ApplicationService
@updated_issue.root_id = @root_id unless @root_id.nil? #不为 nil的时候更新
@updated_issue.root_id = nil if @root_id.try(:zero?) #为 0 的时候设置为 nil
@updated_issue.time_scale = @time_scale unless @time_scale.nil?
if @project_id.present? && @updated_issue.project_id.to_i == 0
add_project = Project.find_by(id: @project_id)
@updated_issue.project_issues_index = add_project.get_last_project_issues_index + 1 if add_project.present?
end
@updated_issue.project_id = @project_id unless @project_id.nil?
@updated_issue.updated_on = Time.now
@updated_issue.changer_id = @current_user.id
@updated_issue.due_date = Time.now if @updated_issue.status_id == 5 && @due_date.blank?
@updated_issue.save!
build_after_issue_journal_details if @updated_issue.previous_changes.present? # 操作记录

View File

@ -23,8 +23,8 @@ class Api::V1::Users::DeleteUserService < ApplicationService
end
@user.destroy!
del_user_data_by_sql(@user.id)
Gitea::User::DeleteService.call(@user.login, true)
end
Gitea::User::DeleteService.call(@user.login, true)
return true
rescue
raise Error, "服务器错误,请联系系统管理员!"
@ -32,11 +32,7 @@ class Api::V1::Users::DeleteUserService < ApplicationService
end
def del_user_data_by_sql(user_id)
if ActiveRecord::Base.connection.table_exists?("memos")
sql1 = "delete from memos where author_id=#{user_id}"
ActiveRecord::Base.connection.execute(sql1)
else
Rails.logger.info "memos table does not exist"
end
sql1 = "delete from memos where author_id=#{user_id}"
ActiveRecord::Base.connection.execute(sql1)
end
end

View File

@ -1,6 +1,5 @@
class Api::V1::Users::UpdateEmailService < ApplicationService
include ActiveModel::Model
include AesCryptHelper
attr_reader :user, :token, :password, :mail, :old_mail, :code, :verify_code
attr_accessor :gitea_data
@ -11,7 +10,7 @@ class Api::V1::Users::UpdateEmailService < ApplicationService
def initialize(user, params, token =nil)
@user = user
@token = token
@password = decrypt(params[:password]) rescue params[:password].to_s
@password = params[:password]
@mail = params[:email]
@old_mail = user.mail
@code = params[:code]

View File

@ -1,6 +1,5 @@
class Api::V1::Users::UpdatePhoneService < ApplicationService
include ActiveModel::Model
include AesCryptHelper
attr_reader :user, :password, :phone, :code, :verify_code
@ -9,7 +8,7 @@ class Api::V1::Users::UpdatePhoneService < ApplicationService
def initialize(user, params)
@user = user
@password = decrypt(params[:password]) rescue params[:password].to_s
@password = params[:password]
@phone = params[:phone]
@code = params[:code]
@verify_code = VerificationCode.where(phone: @phone, code_type: 4).last

View File

@ -56,11 +56,6 @@ class Cache::V2::PlatformStatisticService < ApplicationService
"max-issue-count"
end
# 平台最高已解决issue数
def max_complete_issue_count_key
"max-complete-issue-count"
end
# 平台最高commit数
def max_commit_count_key
"max-commit-count"
@ -91,11 +86,6 @@ class Cache::V2::PlatformStatisticService < ApplicationService
"max-recent-one-month-commit-count"
end
# 平台近一个月release最大值
def max_recent_one_month_release_count_key
"max-recent-one-month-release-count"
end
def follow_count_key
"follow-count"
end
@ -226,11 +216,6 @@ class Cache::V2::PlatformStatisticService < ApplicationService
$redis_cache.hset(platform_statistic_key, max_issue_count_key, max_issue[1].nil? ? 0 : max_issue[1])
end
def reset_platform_max_complete_issue_count
max_complete_issue = Issue.where.not(project_id: 0).issue_issue.where(status_id: [3,5]).group(:project_id).count.sort_by{|i|i[1]}.last || []
$redis_cache.hset(platform_statistic_key, max_complete_issue_count_key, max_complete_issue[1].nil? ? 0 : max_complete_issue[1])
end
def reset_platform_max_commit_count
max_commit = CommitLog.joins(:project).merge(Project.common).group(:project_id).count.sort_by{|i|i[1]}.last || []
$redis_cache.hset(platform_statistic_key, max_commit_count_key, max_commit[1].nil? ? 0 : max_commit[1])
@ -252,7 +237,7 @@ class Cache::V2::PlatformStatisticService < ApplicationService
end
def reset_platform_max_recent_one_month_issue_count
max_recent_one_month_issue = Issue.where.not(project_id: 0).issue_issue.where("created_on > ?", Time.now - 30.days).group(:project_id).count.sort_by{|i|i[1]}.last || []
max_recent_one_month_issue = Issue.issue_issue.where("created_on > ?", Time.now - 30.days).group(:project_id).count.sort_by{|i|i[1]}.last || []
$redis_cache.hset(platform_statistic_key, max_recent_one_month_issue_count_key, max_recent_one_month_issue[1].nil? ? 0 : max_recent_one_month_issue[1])
end
@ -261,11 +246,6 @@ class Cache::V2::PlatformStatisticService < ApplicationService
$redis_cache.hset(platform_statistic_key, max_recent_one_month_commit_count_key, max_recent_one_month_commit[1].nil? ? 0 : max_recent_one_month_commit[1])
end
def reset_platform_max_recent_one_month_release_count
max_recent_one_month_release = VersionRelease.where("created_at >?", Time.now - 30.days).group(:repository_id).count.sort_by{|i|i[1]}.last || []
$redis_cache.hset(platform_statistic_key, max_recent_one_month_release_count_key, max_recent_one_month_release[1].nil? ? 0 : max_recent_one_month_release[1])
end
def reset_platform_follow_count
$redis_cache.hset(platform_statistic_key, follow_count_key, Watcher.where(watchable_type: 'User').count)
end
@ -275,7 +255,7 @@ class Cache::V2::PlatformStatisticService < ApplicationService
end
def reset_platform_issue_count
$redis_cache.hset(platform_statistic_key, issue_count_key, Issue.where.not(project_id: 0).count)
$redis_cache.hset(platform_statistic_key, issue_count_key, Issue.count)
end
def reset_platform_project_count
@ -319,8 +299,6 @@ class Cache::V2::PlatformStatisticService < ApplicationService
reset_platform_max_recent_one_month_pullrequest_count
reset_platform_max_recent_one_month_issue_count
reset_platform_max_recent_one_month_commit_count
reset_platform_max_recent_one_month_release_count
reset_platform_max_complete_issue_count
$redis_cache.hgetall(platform_statistic_key)
end

View File

@ -87,22 +87,14 @@ class Cache::V2::UserDateRankService < ApplicationService
def set_user_rank
set_user_statistic
follow_count = $redis_cache.hget(user_date_statistic_key, "follow-count") || 0
follow_count = follow_count.to_i < 0 ? 0 : follow_count
pullrequest_count = $redis_cache.hget(user_date_statistic_key, "pullrequest-count") || 0
pullrequest_count = pullrequest_count.to_i < 0 ? 0 : pullrequest_count
issues_count = $redis_cache.hget(user_date_statistic_key, "issue-count") || 0
issues_count = issues_count.to_i < 0 ? 0 : issues_count
project_count = $redis_cache.hget(user_date_statistic_key, "project-count") || 0
project_count = project_count.to_i < 0 ? 0 : project_count
fork_count = $redis_cache.hget(user_date_statistic_key, "fork-count") || 0
fork_count = fork_count.to_i < 0 ? 0 : fork_count
project_watchers_count = $redis_cache.hget(user_date_statistic_key, "project-watcher-count") || 0
project_watchers_count = project_watchers_count.to_i < 0 ? 0 : project_watchers_count
project_praises_count = $redis_cache.hget(user_date_statistic_key, "project-praise-count") || 0
project_praises_count = project_praises_count.to_i < 0 ? 0 : project_praises_count
project_language = $redis_cache.hget(user_date_statistic_key, "project-language")
project_languages_count = project_language.nil? || project_language == "{}" ? 0 : JSON.parse(project_language).length
project_languages_count = project_languages_count.to_i < 0 ? 0 : project_languages_count
# 影响力
influence = (60.0 + follow_count.to_i / (follow_count.to_i + 20.0) * 40.0).to_i

View File

@ -39,14 +39,14 @@ class InfoRiskControlService < ApplicationService
def remote_ip_risk_control
result = Rails.cache.read("InfoRiskControlService-RemoteIp-#{remote_ip}")
if result.present?
if result.to_i > 30
if result.to_i > 20
@status = 0
@message = "暂时无法请求,请稍后再试"
else
Rails.cache.write("InfoRiskControlService-RemoteIp-#{remote_ip}", result.to_i + 1)
end
else
Rails.cache.write("InfoRiskControlService-RemoteIp-#{remote_ip}", 1, expires_in: 2.hours)
Rails.cache.write("InfoRiskControlService-RemoteIp-#{remote_ip}", 1, expires_in: 1.day)
end
end

View File

@ -31,7 +31,6 @@ class Projects::TransferService < ApplicationService
project.members.map{|m| m.destroy! if m.user_id == owner.id || project.member(new_owner.id) || (new_owner.is_a?(Organization) && new_owner.is_member?(m.user_id)) }
project.update!(user_id: new_owner.id)
project.set_owner_permission(new_owner)
project.pinned_projects.destroy_all # 移除原来精选的项目
end
def update_actions

View File

@ -1,10 +1,8 @@
class Users::RegisterService < ApplicationService
include AesCryptHelper
def initialize(params)
@login = params[:login]
@namespace = params[:namespace]
@password = decrypt(params[:password]) rescue params[:password].to_s
@password = params[:password]
@code = params[:code]
end

View File

@ -23,10 +23,6 @@
<%= form.label :description, "描述" %>
<%= form.text_area :description, rows: 5, :style => 'width:800px;' %>
</div>
<div class="field">
<%= form.label :default_value, "默认值" %>
<%= form.text_field :default_value %>
</div>
<div class="field">
<%= form.label :is_required, "是否必填项" %>
<%= form.check_box("is_required", {}, "true", "false") %>

View File

@ -1,4 +1,4 @@
json.extract! node_input, :id, :name, :input_type, :description, :is_required, :default_value
json.extract! node_input, :id, :name, :input_type, :description
if node_input.input_type.to_s == "select"
json.select node.action_node_selects do |node_select|
json.partial! "node_select", locals: { node_select: node_select, node: node }

View File

@ -27,10 +27,6 @@
<%= form.label :description, "描述" %>
<%= form.text_area :description, rows: 5, :style => 'width:800px;' %>
</div>
<div class="field">
<%= form.label :default_value, "默认值" %>
<%= form.text_field :default_value %>
</div>
<div class="field">
<%= form.label :is_required, "是否必填项" %>
<%= form.check_box("is_required", {}, "true", "false") %>

View File

@ -11,7 +11,7 @@
<!-- </div>-->
<%# end %>
<div class="form-group ">
<label for="status">节点分类:</label>
<label for="status">类</label>
<%= form.select :action_node_types_id, options_for_select(Action::NodeType.all.map { |key| [key.name, key.id]}, node.action_node_types_id), {}, class: "form-control" %>
</div>
<div class="field">
@ -26,22 +26,6 @@
<%= form.label :full_name, "节点全名" %>
<%= form.text_field :full_name %>
</div>
<div class="form-group ">
<label for="status">类型:</label>
<% node_type_options = [['action节点', 'step' ], ['启动', 'start' ], ['任务', 'job']] %>
<%= form.select :node_type, options_for_select(node_type_options, node.node_type), {}, class: "form-control" %>
</div>
<div class="form-group ">
<label for="status">是否支持分支:</label>
<% is_mutil_link_options = [['否', false ], ['是', true]] %>
<%= form.select :is_mutil_link, options_for_select(is_mutil_link_options, node.is_mutil_link), {}, class: "form-control" %>
</div>
<div class="form-group ">
<label for="status">可连接到类型:</label>
<% link_type_options = [Action::Node.new(name: "job", label: "任务"), Action::Node.new(name: "step", label: "action节点")] %>
<%= collection_check_boxes(:node, :link_type_array, link_type_options, :name, :label) %>
</div>
<div class="field">
<%= form.label :description, "描述" %>

View File

@ -1,4 +1,4 @@
json.extract! node_input, :id, :name, :input_type, :description, :is_required, :default_value
json.extract! node_input, :id, :name, :input_type, :description, :is_required
if node_input.input_type.to_s == "select"
json.select node.action_node_selects do |node_select|
json.partial! "node_select", locals: { node_select: node_select, node: node }

View File

@ -5,15 +5,6 @@
<p><a href="<%= action_templates_path %>" style="font-size: 14px;">>>前往模板配置</a></p>
<p>说明该界面适用于action 节点配置参数配置</p>
<div class="box search-form-container edu_settings-list-form">
<%= form_tag(action_nodes_path, method: :get, class: 'form-inline search-form flex-1') do %>
<%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '关键字检索') %>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
<input type="reset" class="btn btn-secondary clear-btn" value="清空"/>
<% end %>
<%= link_to "新增", new_action_node_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %>
</div>
<table border="1" width="100%">
<thead>
<tr>

View File

@ -2,7 +2,7 @@ json.types @node_types.each do |node_type|
if node_type.name.to_s == "未分类"
json.extract! node_type, :id, :name
json.nodes @no_type_nodes do |node|
json.extract! node, :id, :label, :name, :full_name, :description, :icon, :action_node_types_id, :yaml, :sort_no, :use_count, :node_type, :is_mutil_link, :link_type
json.extract! node, :id, :label, :name, :full_name, :description, :icon, :action_node_types_id, :yaml, :sort_no, :use_count
json.inputs node.action_node_inputs do |node_input|
json.partial! "node_input", locals: { node_input: node_input, node: node }
end
@ -10,7 +10,7 @@ json.types @node_types.each do |node_type|
else
json.extract! node_type, :id, :name
json.nodes node_type.action_nodes do |node|
json.extract! node, :id, :label, :name, :full_name, :description, :icon, :action_node_types_id, :yaml, :sort_no, :use_count, :node_type, :is_mutil_link, :link_type
json.extract! node, :id, :label, :name, :full_name, :description, :icon, :action_node_types_id, :yaml, :sort_no, :use_count
json.inputs node.action_node_inputs do |node_input|
json.partial! "node_input", locals: { node_input: node_input, node: node }
end

View File

@ -1,7 +1,7 @@
json.status 0
json.message "success"
json.extract! @node, :id, :name, :full_name, :description, :icon, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no, :use_count, :label, :node_type, :is_mutil_link, :link_type
json.extract! @node, :id, :name, :full_name, :description, :action_node_types_id, :is_local, :local_url, :yaml, :sort_no, :use_count
json.inputs @node.action_node_inputs do |node_input|
json.partial! "node_input", locals: { node_input: node_input, node: @node }
end

View File

@ -15,7 +15,7 @@
</tr>
</thead>
<tbody>
<% if @pre_week_statistic.present? %>
<% if @current_week_statistic.size ==1 && @pre_week_statistic.present? %>
<tr class="">
<td>上周合计</td>
<td><%= @pre_week_statistic.map(&:pv).sum %></td>

View File

@ -12,15 +12,15 @@
<tbody>
<% if user_nps.present? %>
<% user_nps.each_with_index do |nps, index| %>
<tr class="user-item-<%= nps.user.nil? ? "用户已注销" : nps.user.id %>">
<tr class="user-item-<%= nps.user.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td class="text-left">
<%= link_to "/#{nps.user.nil? ? "用户已注销" : nps.user.login}", target: '_blank' do %>
<%= overflow_hidden_span (nps.user.nil? ? "用户已注销" : nps.user.real_name), width: 100 %>
<%= link_to "/#{nps.user.login}", target: '_blank' do %>
<%= overflow_hidden_span nps.user.real_name, width: 100 %>
<% end %>
</td>
<td><%= display_text(nps.created_at&.strftime('%Y-%m-%d %H:%M')) %></td>
<td><%= display_text(nps.user.nil? ? "用户已注销" : nps.user.last_login_on&.strftime('%Y-%m-%d %H:%M')) %></td>
<td><%= display_text(nps.user.last_login_on&.strftime('%Y-%m-%d %H:%M')) %></td>
<td><%= nps.action_type == 'close' ? '--' : nps.score %></td>
<td><%= nps.memo %></td>
</tr>

View File

@ -37,21 +37,6 @@
提升用户体验:<span class="text-danger"><%= UserNp.where("memo like '%用户体验需进一步提升%'").count %></span>
其他:<span class="text-danger"><%= UserNp.where("action_type !='close'").where("LENGTH(memo) >0").where.not(id: UserNp.where("memo like '%期待更加丰富的功能%' or memo like '%希望有新手引导%' or memo like '%用户体验需进一步提升%' ").ids).count %></span>
</p>
<p style="padding-bottom: 10px !important;">
代码库基本功能:<span class="text-danger"><%= UserNp.where("memo like '%代码库基本功能%'").count %></span>
疑修:<span class="text-danger"><%= UserNp.where("memo like '%疑修%'").count %></span>
合并请求:<span class="text-danger"><%= UserNp.where("memo like '%合并请求%'").count %></span>
流水线引擎:<span class="text-danger"><%= UserNp.where("memo like '%流水线引擎%'").count %></span>
维基Wiki<span class="text-danger"><%= UserNp.where("memo like '%维基Wiki%'").count %></span>
数据集:<span class="text-danger"><%= UserNp.where("memo like '%数据集%'").count %></span>
特色专区:<span class="text-danger"><%= UserNp.where("memo like '%特色专区%'").count %></span>
BOT功能<span class="text-danger"><%= UserNp.where("memo like '%BOT功能%'").count %></span>
跨平台同步服务:<span class="text-danger"><%= UserNp.where("memo like '%跨平台同步服务%'").count %></span>
代码溯源及扫描服务:<span class="text-danger"><%= UserNp.where("memo like '%代码溯源及扫描服务%'").count %></span>
开源软件健康度量服务:<span class="text-danger"><%= UserNp.where("memo like '%开源软件健康度量服务%'").count %></span>
HiAgent<span class="text-danger"><%= UserNp.where("memo like '%HiAgent%'").count %></span>
非常满意,没有需要吐槽的功能!:<span class="text-danger"><%= UserNp.where("memo like '%非常满意,没有需要吐槽的功能%'").count %></span>
</p>
</div>
<div class="box admin-list-container users-list-container">
<%= render partial: 'admins/nps/user_np_list', locals: { user_nps: @user_nps } %>

View File

@ -51,7 +51,7 @@
<li>
<%= sidebar_item_group('#setting-index', '首页配置', icon: 'file', has_permission: current_user.admin? || current_user.business?) do %>
<li><%= sidebar_item(admins_topic_banners_path, 'banner管理', icon: 'image', controller: 'admins-topic-banners', has_permission: current_user.admin? || current_user.business?) %></li>
<li><%= sidebar_item(admins_topic_cards_path, '卡片管理', icon: 'archive', controller: 'admins-topic-cards', has_permission: current_user.admin? || current_user.business?) %></li>
<!--<li><%#= sidebar_item(admins_topic_cards_path, '卡片管理', icon: 'archive', controller: 'admins-topic-cards', has_permission: current_user.admin? || current_user.business?) %></li>-->
<li><%= sidebar_item(admins_topic_activity_forums_path, '平台动态管理', icon: 'bell', controller: 'admins-topic-activity_forums', has_permission: current_user.admin? || current_user.business?) %></li>
<li><%= sidebar_item(admins_topic_excellent_projects_path, '优秀仓库管理', icon: 'git', controller: 'admins-topic-excellent_projects', has_permission: current_user.admin? || current_user.business?) %></li>
<li><%= sidebar_item(admins_topic_pinned_forums_path, '精选文章管理', icon: 'edit', controller: 'admins-topic-pinned_forums', has_permission: current_user.admin? || current_user.business?) %></li>

View File

@ -1,44 +0,0 @@
<% sidebar_collapse = request.cookies['admin_sidebar_collapse'].to_s == 'true' %>
<nav id="sidebar" class="<%= sidebar_collapse ? 'active' : '' %>" data-current-controller="<%= admin_sidebar_controller %>">
<div class="sidebar-header">
<a href="/" class="sidebar-header-logo" data-toggle="tooltip" data-title="返回主站">
<!-- <img class="rounded-circle" src="/images/<%#= url_to_avatar(current_user) %>" />-->
<span class="logo-label">后台管理</span>
</a>
<div id="sidebarCollapse" class="navbar-btn <%= sidebar_collapse ? 'active' : '' %>">
<i class="fa fa-chevron-left fold" data-toggle="tooltip" data-placement="right" data-boundary="window" title="收起"></i>
<i class="fa fa-bars unfold" data-toggle="tooltip" data-placement="right" data-boundary="window" title="展开"></i>
</div>
</div>
<!-- Sidebar Links -->
<ul class="list-unstyled components">
<li><%= sidebar_item(admins_path, '数据概览', icon: 'dashboard', controller: 'admins-dashboards', has_permission: current_user.admin?) %></li>
<li>
<%= sidebar_item_group('#user-submenu', '用户', icon: 'user', has_permission: current_user.admin?) do %>
<li><%= sidebar_item(admins_users_path, '用户列表', icon: 'user', controller: 'admins-users', has_permission: current_user.admin?) %></li>
<li><%= sidebar_item(admins_organizations_path, '组织列表', icon: 'user', controller: 'admins-organizations', has_permission: current_user.admin?) %></li>
<% end %>
</li>
<li>
<%= sidebar_item_group('#projects-submenu', '开源项目', icon: 'database', has_permission: current_user.admin?) do %>
<li><%= sidebar_item(admins_projects_path, '项目列表', icon: 'database', controller: 'admins-projects', has_permission: current_user.admin?) %></li>
<li><%= sidebar_item(admins_project_languages_path, '项目语言', icon: 'language', controller: 'admins-project_languages', has_permission: current_user.admin?) %></li>
<li><%= sidebar_item(admins_project_categories_path, '分类列表', icon: 'sitemap', controller: 'admins-project_categories', has_permission: current_user.admin?) %></li>
<li><%= sidebar_item(admins_project_licenses_path, '开源许可证', icon: 'file-text-o', controller: 'admins-project_licenses', has_permission: current_user.admin?) %></li>
<li><%= sidebar_item(admins_project_ignores_path, '忽略文件', icon: 'git', controller: 'admins-project_ignores', has_permission: current_user.admin?) %></li>
<% end %>
</li>
<li><%= sidebar_item(admins_laboratories_path, '导航栏配置', icon: 'cloud', controller: 'admins-laboratories', has_permission: current_user.admin?)%></li>
<li>
<%= sidebar_item_group('#setting-system', '开发者配置', icon: 'wrench', has_permission: current_user.admin?) do %>
<li><%= sidebar_item(admins_sites_path, 'setting接口配置', icon: 'deaf', controller: 'admins-sites', has_permission: current_user.admin?) %></li>
<li><%= sidebar_item(admins_edu_settings_path, '全局变量配置', icon: 'pencil-square', controller: 'admins-edu_settings', has_permission: current_user.admin?) %></li>
<!-- <li><%#= sidebar_item(admins_message_templates_path, '消息模版配置', icon: 'folder', controller: 'admins-message_templates', has_permission: current_user.admin?) %></li>-->
<li><%= sidebar_item('/admins/sidekiq', '定时任务', icon: 'bell', controller: 'root', has_permission: current_user.admin?) %></li>
<% end %>
</li>
<li><%= sidebar_item('/', '返回主站', icon: 'sign-out', controller: 'root', has_permission: current_user.admin?) %></li>
</ul>
</nav>

View File

@ -3,11 +3,11 @@
<tr>
<th width="5%">序号</th>
<th width="15%">名称</th>
<th width="35%">路由</th>
<th width="15%">标识</th>
<th width="30%">路由</th>
<th width="20%">标识</th>
<th width="10%">类型</th>
<th width="15%"><%= sort_tag('创建时间', name: 'created_at', path: admins_sites_path) %></th>
<th width="15%">操作</th>
<th width="20%"><%= sort_tag('创建时间', name: 'created_at', path: admins_sites_path) %></th>
<th width="25%">操作</th>
</tr>
</thead>
<tbody>
@ -20,7 +20,7 @@
</td>
<td><%= site.url %></td>
<td><%= overflow_hidden_span display_text(site.key), width: 170 %></td>
<td><%= overflow_hidden_span display_text(site.key), width: 150 %></td>
<td><%= site.site_type.humanize %></td>
<td><%= site.created_at&.strftime('%Y-%m-%d %H:%M') %></td>
<td class="action-container">

View File

@ -6,7 +6,7 @@
<%= form_tag(admins_sites_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
<div class="form-group mr-2">
<label for="status">类型:</label>
<% type_options = [['全部', ''], ['Add', Site.site_types[:add]], ['Personal', Site.site_types[:personal]], ['Common', Site.site_types[:common]], ['Competition', Site.site_types[:competition]]] %>
<% type_options = [['全部', ''], ['Add', Site.site_types[:add]], ['Personal', Site.site_types[:personal]], ['Common', Site.site_types[:common]]] %>
<%= select_tag(:site_type, options_for_select(type_options), class: 'form-control') %>
</div>

View File

@ -1,11 +0,0 @@
json.status 0
json.message "success"
json.data do
json.total_count @issues.total_count
json.my_assign_requirements_count @my_assign_requirements_count
json.my_assign_tasks_count @my_assign_tasks_count
json.my_assign_bugs_count @my_assign_bugs_count
json.issues @issues.each do |issue|
json.partial! "api/v1/issues/simple_detail", locals: {issue: issue}
end
end

Some files were not shown because too many files have changed in this diff Show More