Merge branch 'standalone_develop' into pm_project_develop

This commit is contained in:
yystopf 2024-07-11 10:07:20 +08:00
commit 7dda079ff3
72 changed files with 457 additions and 114 deletions

View File

@ -23,10 +23,23 @@ class Admins::BaseController < ApplicationController
def require_admin!
return if current_user.blank? || !current_user.logged?
return if current_user.admin_or_business?
return if current_user.admin_or_glcc_admin?
render_forbidden
end
def require_admin
render_forbidden unless User.current.admin?
end
def require_business
render_forbidden unless admin_or_business?
end
def require_glcc_admin
render_forbidden unless admin_or_glcc_admin?
end
# 触发after ajax render partial hooks执行一些因为局部刷新后失效的绑定事件
def rebind_event_if_ajax_render_partial
return if request.format.symbol != :js

View File

@ -1,4 +1,5 @@
class Admins::EduSettingsController < Admins::BaseController
before_action :require_admin
before_action :find_setting, only: [:edit,:update, :destroy]
def index

View File

@ -1,4 +1,5 @@
class Admins::FaqsController < Admins::BaseController
before_action :require_business
before_action :find_faq, only: [:edit,:update, :destroy]
def index

View File

@ -1,4 +1,5 @@
class Admins::FeedbacksController < Admins::BaseController
before_action :require_business
before_action :get_feedback, only: [:new_history, :create_history, :destroy]
def index

View File

@ -1,4 +1,6 @@
class Admins::GlccPrCheckController < Admins::BaseController
before_action :require_glcc_admin
def index
params[:sort_by] = params[:sort_by].presence || 'created_on'
params[:sort_direction] = params[:sort_direction].presence || 'desc'

View File

@ -1,4 +1,5 @@
class Admins::IdentityVerificationsController < Admins::BaseController
before_action :require_business
before_action :finder_identity_verification, except: [:index]
def index
params[:sort_by] = params[:sort_by].presence || 'created_at'

View File

@ -1,4 +1,5 @@
class Admins::IssuesRankController < Admins::BaseController
before_action :require_admin
def index
@statistics = DailyProjectStatistic.where('date >= ? AND date <= ?', begin_date, end_date)

View File

@ -1,4 +1,5 @@
class Admins::LaboratoriesController < Admins::BaseController
before_action :require_admin
def index
default_sort('id', 'desc')

View File

@ -1,4 +1,5 @@
class Admins::MessageTemplatesController < Admins::BaseController
before_action :require_admin
before_action :get_template, only: [:edit, :update, :destroy]
def index
@ -7,12 +8,12 @@ class Admins::MessageTemplatesController < Admins::BaseController
end
def new
@message_template = MessageTemplate.new
@message_template = MessageTemplate::CustomTip.new
end
def create
@message_template = MessageTemplate::CustomTip.new(message_template_params)
@message_template.type = "MessageTemplate::CustomTip"
def create
@message_template = MessageTemplate::CustomTip.new
@message_template.attributes = message_template_params
if @message_template.save!
redirect_to admins_message_templates_path
flash[:success] = "创建消息模板成功"
@ -47,9 +48,7 @@ class Admins::MessageTemplatesController < Admins::BaseController
private
def message_template_params
# type = @message_template.present? ? @message_template.type : "MessageTemplate::CustomTip"
# params.require(type.split("::").join("_").underscore.to_sym).permit!
params.require(:message_template_custom_tip).permit!
params.require(@message_template.type.split("::").join("_").underscore.to_sym).permit!
end
def get_template

View File

@ -1,4 +1,5 @@
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.joins(:user).order(created_at: :desc)

View File

@ -1,5 +1,6 @@
class Admins::OrganizationsController < Admins::BaseController
before_action :finder_org, except: [:index]
before_action :require_admin
before_action :finder_org, except: [:index]
def index
params[:sort_by] = params[:sort_by].presence || 'created_on'

View File

@ -1,4 +1,5 @@
class Admins::PageThemesController < Admins::BaseController
before_action :require_admin
before_action :finder_page_theme, only: [:edit, :update, :destroy]
def index

View File

@ -1,4 +1,5 @@
class Admins::ProjectCategoriesController < Admins::BaseController
before_action :require_admin
before_action :get_category, only: [:edit,:update, :destroy]
before_action :validate_names, only: [:create, :update]

View File

@ -1,4 +1,5 @@
class Admins::ProjectIgnoresController < Admins::BaseController
before_action :require_admin
before_action :set_ignore, only: [:edit,:update, :destroy,:show]
# before_action :validate_params, only: [:create, :update]

View File

@ -1,4 +1,5 @@
class Admins::ProjectLanguagesController < Admins::BaseController
before_action :require_admin
before_action :get_language, only: [:edit,:update, :destroy]
before_action :validate_names, only: [:create, :update]

View File

@ -1,4 +1,5 @@
class Admins::ProjectLicensesController < Admins::BaseController
before_action :require_admin
before_action :set_license, only: [:edit,:update, :destroy,:show]
# before_action :validate_params, only: [:create, :update]

View File

@ -1,4 +1,5 @@
class Admins::ProjectsController < Admins::BaseController
before_action :require_admin
before_action :find_project, only: [:edit, :update]
def index
@ -32,7 +33,7 @@ class Admins::ProjectsController < Admins::BaseController
def destroy
project = Project.find_by!(id: params[:id])
ActiveRecord::Base.transaction do
Gitea::Repository::DeleteService.new(project.owner, project.identifier).call
Gitea::Repository::DeleteService.new(project.owner, project.identifier, current_user.gitea_token).call
project.destroy!
# render_delete_success
UserAction.create(action_id: project.id, action_type: "DestroyProject", user_id: current_user.id, :ip => request.remote_ip, data_bank: project.attributes.to_json)

View File

@ -1,4 +1,6 @@
class Admins::ProjectsRankController < Admins::BaseController
before_action :require_admin
def index
@statistics = DailyProjectStatistic.where("date >= ? AND date <= ?", begin_date, end_date)
@statistics = @statistics.group(:project_id).select("project_id,
@ -10,7 +12,7 @@ class Admins::ProjectsRankController < Admins::BaseController
sum(issues) as issues,
sum(pullrequests) as pullrequests,
sum(commits) as commits").includes(:project)
@statistics = @statistics.order("#{sort_by} #{sort_direction}")
@statistics = paginate @statistics.order("#{sort_by} #{sort_direction}")
export_excel(@statistics.limit(50))
end

View File

@ -1,4 +1,5 @@
class Admins::ReversedKeywordsController < Admins::BaseController
before_action :require_admin
before_action :get_keyword, only: [:edit,:update, :destroy]
# before_action :validate_identifer, only: [:create, :update]

View File

@ -1,4 +1,5 @@
class Admins::SitePagesController < Admins::BaseController
before_action :require_admin
before_action :finder_site_page, except: [:index]
def index

View File

@ -1,4 +1,5 @@
class Admins::SitesController < Admins::BaseController
before_action :require_admin
before_action :find_site, only: [:edit,:update, :destroy]
def index

View File

@ -1,4 +1,5 @@
class Admins::SystemNotificationsController < Admins::BaseController
before_action :require_business
before_action :get_notification, only: [:history, :edit,:update, :destroy]
# before_action :validate_identifer, only: [:create, :update]

View File

@ -1,4 +1,5 @@
class Admins::Topic::ActivityForumsController < Admins::Topic::BaseController
before_action :require_business
before_action :find_activity_forum, only: [:edit, :update, :destroy]
def index

View File

@ -1,4 +1,5 @@
class Admins::Topic::BannersController < Admins::Topic::BaseController
before_action :require_business
before_action :find_banner, only: [:edit, :update, :destroy]
def index

View File

@ -1,4 +1,5 @@
class Admins::Topic::CardsController < Admins::Topic::BaseController
before_action :require_business
before_action :find_card, only: [:edit, :update, :destroy]
def index

View File

@ -1,4 +1,5 @@
class Admins::Topic::CooperatorsController < Admins::Topic::BaseController
before_action :require_business
before_action :find_cooperator, only: [:edit, :update, :destroy]
def index

View File

@ -1,4 +1,5 @@
class Admins::Topic::ExcellentProjectsController < Admins::Topic::BaseController
before_action :require_business
before_action :find_excellent_project, only: [:edit, :update, :destroy]
def index

View File

@ -1,4 +1,5 @@
class Admins::Topic::ExperienceForumsController < Admins::Topic::BaseController
before_action :require_business
before_action :find_experience_forum, only: [:edit, :update, :destroy]
def index

View File

@ -1,4 +1,5 @@
class Admins::Topic::GlccNewsController < Admins::Topic::BaseController
before_action :require_glcc_admin
before_action :find_glcc, only: [:edit, :update, :destroy]
def index

View File

@ -1,4 +1,5 @@
class Admins::Topic::PinnedForumsController < Admins::Topic::BaseController
before_action :require_business
before_action :find_pinned_forum, only: [:edit, :update, :destroy]
def index

View File

@ -1,4 +1,5 @@
class Admins::UsersController < Admins::BaseController
before_action :require_admin
before_action :finder_user, except: [:index]
def index
@ -73,6 +74,6 @@ class Admins::UsersController < Admins::BaseController
def update_params
params.require(:user).permit(%i[lastname nickname gender technical_title is_shixun_marker
mail phone location location_city school_id department_id admin
password login website_permission])
password login website_permission business glcc_admin])
end
end

View File

@ -1,4 +1,5 @@
class Admins::UsersRankController < Admins::BaseController
before_action :require_admin
def index
@rank_date = rank_date

View File

@ -0,0 +1,52 @@
class Api::V1::Projects::PortraitController < Api::V1::BaseController
before_action :require_public_and_member_above
def index
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)
# 项目成熟度
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)
# 项目健康度
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
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
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_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
end

View File

@ -75,7 +75,11 @@ class ApplicationController < ActionController::Base
def admin_or_business?
User.current.admin? || User.current.business?
User.current.admin? || User.current.business?
end
def admin_or_glcc_admin?
User.current.admin? || User.current.glcc_admin?
end
# 判断用户的邮箱或者手机是否可用
@ -195,6 +199,10 @@ class ApplicationController < ActionController::Base
normal_status(403, "") unless admin_or_business?
end
def require_glcc_admin
normal_status(403, "") unless admin_or_glcc_admin?
end
# 前端会捕捉401,弹登录弹框
# 未授权的捕捉407弹试用申请弹框
def require_login

View File

@ -36,6 +36,8 @@ class ProjectsController < ApplicationController
def index
scope = current_user.logged? ? Projects::ListQuery.call(params, current_user.id) : Projects::ListQuery.call(params)
# scope = scope.joins(repository: :mirror).where.not(mirrors: {status: 2}) # 导入失败项目不显示
@projects = kaminari_paginate(scope.includes(:project_category, :project_language, :repository, :project_educoder, :owner, :project_units, :project_topics))
# @projects = paginate scope.includes(:project_category, :project_language, :repository, :project_educoder, :owner, :project_units)
@ -62,7 +64,8 @@ class ProjectsController < ApplicationController
end
rescue Gitea::Api::ServerError => ex
uid_logger_error(ex.message)
tip_exception(ex.http_code, ex.message)
# tip_exception(ex.http_code, ex.message)
tip_exception(ex.message)
rescue ApplicationService::Error => e
uid_logger_error(e.message)
tip_exception(e.message)
@ -214,7 +217,7 @@ class ProjectsController < ApplicationController
new_project_params = project_params.except(:private).merge(is_public: !private)
@project.update_attributes!(new_project_params)
@project.forked_projects.update_all(is_public: @project.is_public)
@project.forked_projects.map{|p| p.update!(is_public: @project.is_public)}
gitea_params = {
private: private,
default_branch: @project.default_branch,
@ -246,7 +249,7 @@ class ProjectsController < ApplicationController
def destroy
if current_user.admin? || @project.manager?(current_user)
ActiveRecord::Base.transaction do
Gitea::Repository::DeleteService.new(@project.owner, @project.identifier).call
Gitea::Repository::DeleteService.new(@project.owner, @project.identifier,current_user.gitea_token).call
@project.destroy!
@project.forked_projects.update_all(forked_from_project_id: nil)
# 如果该项目有所属的项目分类以及为私有项目,需要更新对应数量
@ -296,6 +299,30 @@ class ProjectsController < ApplicationController
end
def simple
if !@project.common? && @project&.repository&.mirror&.waiting?
gitea_result = $gitea_client.get_repos_by_owner_repo(@project&.owner&.login, @project&.identifier)
if !gitea_result["empty"]
@project&.update_columns(gpid: gitea_result["id"])
@project&.repository&.mirror&.succeeded!
project_id = @project&.id
user_id = @project&.owner&.id
Rails.logger.info "############ mirror project_id,user_id: #{project_id},#{user_id} ############"
OpenProjectDevOpsJob.set(wait: 5.seconds).perform_later(project_id, user_id) if project_id.present? && user_id.present?
UpdateProjectTopicJob.set(wait: 1.seconds).perform_later(project_id) if project_id.present?
Rails.logger.info "############ mirror status: #{@project&.repository&.mirror&.status} ############"
end
elsif !@project.common? && @project&.repository&.mirror&.failed?
# 导入失败的项目标记 project.status=0, 在列表中不显示
@project&.update_columns(status: 0) if @project&.status == 1
# Rails.logger.info "############ mirror status: #{@project&.repository&.mirror&.status}"
# Gitea::Repository::DeleteService.new(@project.owner, @project.identifier,current_user.gitea_token).call
# @project.destroy!
# @project.forked_projects.update_all(forked_from_project_id: nil)
# # 如果该项目有所属的项目分类以及为私有项目,需要更新对应数量
# @project.project_category.decrement!(:private_projects_count, 1) if @project.project_category.present? && !@project.is_public
# return render_error("导入失败,请重试!")
end
# 为了缓存活跃项目的基本信息,后续删除
Cache::V2::ProjectCommonService.new(@project.id).read
# 项目名称,标识,所有者变化时重置缓存

View File

@ -7,6 +7,7 @@ class RepositoriesController < ApplicationController
before_action :require_login, only: %i[edit update create_file update_file delete_file sync_mirror]
before_action :require_profile_completed, only: [:create_file]
before_action :load_repository
before_action :require_operate_above, only: %i[create_file update_file replace_file delete_file]
before_action :authorizate!, except: [:sync_mirror, :tags, :commit, :archive]
before_action :authorizate_user_can_edit_repo!, only: %i[sync_mirror]
before_action :get_ref, only: %i[entries sub_entries top_counts files archive]
@ -437,4 +438,8 @@ class RepositoriesController < ApplicationController
end
end
def require_operate_above
return render_forbidden if !current_user.admin? && !@project.operator?(current_user)
end
end

View File

@ -702,6 +702,15 @@ class UsersController < ApplicationController
@user = User.find_by(mail: params[:email])
end
#根据login获取用户信息
def get_user_info_by_login
private_token = "hriEn3UwXfJs3PmyXnSH"
sign = Digest::MD5.hexdigest("#{private_token}:#{params[:login]}")
tip_exception(401, '401 Unauthorized') unless params[:sign].to_s == sign
user = User.find_by_login params[:login]
render_ok(data: {username: user.real_name, school: user.custom_department, login: user.login, phone: user.phone, mail: user.mail})
end
private
def load_user
@user = User.find_by_login(params[:id]) || User.find_by(id: params[:id])
@ -731,7 +740,7 @@ class UsersController < ApplicationController
end
def sso_login
if params[:login].present? && !current_user.logged? && params[:websiteName].present?
if params[:login].present? && !current_user.logged? && params[:websiteName].present? && request.referer.to_s.include?("gitlink.org.cn")
user = User.where("login = ?", "#{params[:login].presence}").first
# 已同步注册,直接登录
if user.present?

View File

@ -2,8 +2,8 @@ class VersionReleasesController < ApplicationController
include ApplicationHelper
before_action :load_repository
before_action :set_user
before_action :require_login, except: [:index, :show]
before_action :check_release_authorize, except: [:index, :show]
before_action :require_login, except: [:index, :show, :download]
before_action :check_release_authorize, except: [:index, :show, :download]
before_action :find_version , only: [:show, :edit, :update, :destroy]
def index
@ -157,7 +157,7 @@ class VersionReleasesController < ApplicationController
name: params[:name],
prerelease: params[:prerelease] || false,
tag_name: params[:tag_name],
target_commitish: params[:target_commitish] || "master" #分支
target_commitish: params[:target_commitish] || @project.default_branch #分支
}
end

View File

@ -26,6 +26,16 @@ class BaseForm
raise "项目标识已被使用." if Repository.where(user_id: user_id, identifier: repository_name.strip).exists?
end
def check_gitea_repository_name(user_id, repository_name)
user_login = User.find_by_id(user_id)&.login
begin
gitea_result = $gitea_client.get_repos_by_owner_repo(user_login, repository_name)
raise "项目标识已被使用." if gitea_result["id"].present?
rescue Gitea::Api::ServerError => e
raise "服务器错误,请联系系统管理员!" unless e.http_code.to_i == 404
end
end
def check_project_name(user_id, project_name)
raise "项目名称已被使用." if Project.where(user_id: user_id, name: project_name.strip).exists?
end

View File

@ -16,6 +16,7 @@ class Projects::CreateForm < BaseForm
check_project_language(project_language_id)
check_project_name(user_id, name) unless name.blank?
check_repository_name(user_id, repository_name) unless repository_name.blank?
# check_gitea_repository_name(user_id, repository_name) unless repository_name.blank?
check_blockchain_token_all(blockchain_token_all) unless blockchain_token_all.blank?
check_blockchain_init_token(blockchain_init_token) unless blockchain_init_token.blank?
end

View File

@ -11,6 +11,7 @@ class Projects::MigrateForm < BaseForm
validate do
check_project_name(user_id, name) unless name.blank?
check_repository_name(user_id, repository_name) unless repository_name.blank?
# check_gitea_repository_name(user_id, repository_name) unless repository_name.blank?
check_project_category(project_category_id)
check_project_language(project_language_id)
check_owner

View File

@ -10,6 +10,7 @@ class Projects::UpdateForm < BaseForm
check_project_language(project_language_id)
check_repository_name(user_id, identifier) unless identifier.blank? || identifier == project_identifier
# check_gitea_repository_name(user_id, identifier) unless identifier.blank? || identifier == project_identifier
check_project_name(user_id, name) unless name.blank? || name == project_name
end

View File

@ -2,29 +2,33 @@ module ManageBackHelper
extend ActiveSupport::Concern
def sidebar_item_group(url, text, **opts)
link_opts = url.start_with?('/') ? {} : { 'data-toggle': 'collapse', 'aria-expanded': false }
content =
link_to url, link_opts do
content_tag(:i, '', class: "fa fa-#{opts[:icon]}", 'data-toggle': 'tooltip', 'data-placement': 'right', 'data-boundary': 'window', title: text) +
content_tag(:span, text)
end
if opts[:has_permission]
link_opts = url.start_with?('/') ? {} : { 'data-toggle': 'collapse', 'aria-expanded': false }
content =
link_to url, link_opts do
content_tag(:i, '', class: "fa fa-#{opts[:icon]}", 'data-toggle': 'tooltip', 'data-placement': 'right', 'data-boundary': 'window', title: text) +
content_tag(:span, text)
end
content +=
content_tag(:ul, id: url[1..-1], class: 'collapse list-unstyled', "data-parent": '#sidebar') do
yield
end
content +=
content_tag(:ul, id: url[1..-1], class: 'collapse list-unstyled', "data-parent": '#sidebar') do
yield
end
raw content
raw content
end
end
def sidebar_item(url, text, **opts)
content =
link_to url, 'data-controller': opts[:controller] do
content_tag(:i, '', class: "fa fa-#{opts[:icon]} fa-fw", 'data-toggle': 'tooltip', 'data-placement': 'right', 'data-boundary': 'window', title: text) +
content_tag(:span, text)
end
if opts[:has_permission]
content =
link_to url, 'data-controller': opts[:controller] do
content_tag(:i, '', class: "fa fa-#{opts[:icon]} fa-fw", 'data-toggle': 'tooltip', 'data-placement': 'right', 'data-boundary': 'window', title: text) +
content_tag(:span, text)
end
raw content
raw content
end
end
def admin_sidebar_controller

View File

@ -68,6 +68,7 @@ module ProjectsHelper
cloud_ide_saas_url: cloud_ide_saas_url(user),
open_blockchain: Site.has_blockchain? && project.use_blockchain,
has_dataset: project.project_dataset.present?,
open_portrait: project.open_portrait,
ignore_id: project.ignore_id
}).compact

View File

@ -147,6 +147,7 @@ module RepositoriesHelper
ss_href = content.to_s.scan(href_regex)
ss_href_1 = content.to_s.scan(href_regex_1)
total_sources = {ss_c: ss_c,ss: ss, ss_1: ss_1, ss_2: ss_2, ss_src: ss_src, ss_src_1: ss_src_1, ss_src_2: ss_src_2, ss_src_3: ss_src_3, ss_src_4: ss_src_4, ss_src_5: ss_src_5, ss_href: ss_href, ss_href_1: ss_href_1}
puts total_sources
# total_sources.uniq!
total_sources.except(:ss, :ss_c).each do |k, sources|
sources.each do |s|
@ -210,12 +211,14 @@ module RepositoriesHelper
end
end
after_ss_souces = content.to_s.scan(s_regex)
after_ss_souces = content.to_s.scan(s_regex)#.uniq
after_ss_souces.each_with_index do |s, index|
next if total_sources[:ss][index].nil?
content = content.gsub("#{s[0]}","#{total_sources[:ss][index][0]}")
end
after_ss_c_souces = content.to_s.scan(s_regex_c)
after_ss_c_souces = content.to_s.scan(s_regex_c)#.uniq
after_ss_c_souces.each_with_index do |s, index|
next if total_sources[:ss_c][index].nil?
content = content.gsub("#{s[0]}","#{total_sources[:ss_c][index][0]}")
end
return content

View File

@ -2,6 +2,7 @@ class CacheAsyncClearJob < ApplicationJob
queue_as :cache
def perform(type, id=nil)
return if id.nil?
case type
when "project_common_service"
Cache::V2::ProjectCommonService.new(id).clear

View File

@ -11,7 +11,7 @@ class CheckMirrorJob < ApplicationJob
unless response.present?
SyncLog.sync_log("==========check_project_error_id:#{project.id}============")
ActiveRecord::Base.transaction do
delete_gitea = Gitea::Repository::DeleteService.new(project.owner, project.identifier).call
delete_gitea = Gitea::Repository::DeleteService.new(project.owner, project.identifier, project.owner.gitea_token).call
if delete_gitea.status == 204 || delete_gitea.status == 404 #删除成功或者仓库不存在,都重新创建
repository_params= {
name: project.identifier,

View File

@ -12,7 +12,7 @@ class DailyPlatformStatisticsJob < ApplicationJob
ActiveJob::Base.logger.info "job baidu_tongji_auth access_token ===== #{access_token}"
# 从最后一个记录日期开始,如果遗漏日期数据可以补充数据
last_date = DailyPlatformStatistic.order(:date).last
start_date = last_date.date
start_date = last_date.present? ? last_date.date : 1.days.ago.beginning_of_day
end_date = Time.now
if access_token.present?
tongji_service.overview_batch_add(start_date, end_date)

View File

@ -10,7 +10,7 @@ class MigrateRemoteRepositoryJob < ApplicationJob
gitea_repository = Gitea::Repository::MigrateService.new(token, params).call
puts "#gitea_repository#{gitea_repository}"
if gitea_repository[0]==201
repo&.project&.update_columns(gpid: gitea_repository[2]["id"])
repo&.project&.update_columns(gpid: gitea_repository[2]["id"], default_branch: gitea_repository[2]["default_branch"])
repo&.mirror&.succeeded!
## open jianmu devops
project_id = repo&.project&.id
@ -19,9 +19,21 @@ class MigrateRemoteRepositoryJob < ApplicationJob
UpdateProjectTopicJob.set(wait: 1.seconds).perform_later(project_id) if project_id.present?
puts "############ mirror status: #{repo.mirror.status} ############"
else
repo&.mirror&.failed!
gitea_result = $gitea_client.get_repos_by_owner_repo(repo&.project&.owner&.login, repo&.project&.identifier)
if gitea_result["empty"]
repo&.mirror&.failed!
repo&.project&.update_columns(status: 0)
else
repo&.project&.update_columns(gpid: gitea_repository[2]["id"], default_branch: gitea_repository[2]["default_branch"])
repo&.mirror&.succeeded!
project_id = repo&.project&.id
puts "############ mirror project_id,user_id: #{project_id},#{user_id} ############"
OpenProjectDevOpsJob.set(wait: 5.seconds).perform_later(project_id, user_id) if project_id.present? && user_id.present?
UpdateProjectTopicJob.set(wait: 1.seconds).perform_later(project_id) if project_id.present?
puts "############ mirror status: #{repo.mirror.status} ############"
end
end
# UpdateProjectTopicJob 中语言要延迟1S才能获取
BroadcastMirrorRepoMsgJob.set(wait: 1.seconds).perform_later(repo.id) unless repo&.mirror.waiting?
BroadcastMirrorRepoMsgJob.set(wait: 10.seconds).perform_later(repo.id) unless repo&.mirror.waiting?
end
end

View File

@ -216,4 +216,9 @@ class Organization < Owner
ids.uniq.size
end
# user容错处理
def get_letter_avatar_url
""
end
end

View File

@ -182,14 +182,14 @@ class Project < ApplicationRecord
end
if changes[:is_public].present?
if changes[:is_public][0] && !changes[:is_public][1]
CacheAsyncClearJob.perform_later('project_rank_service', self.id)
CacheAsyncClearJob.set(wait: 5.seconds).perform_later('project_rank_service', self.id)
end
if !changes[:is_public][0] && changes[:is_public][1]
$redis_cache.srem("v2-project-rank-deleted", self.id)
end
end
if !self.common?
CacheAsyncClearJob.perform_later('project_rank_service', self.id)
CacheAsyncClearJob.set(wait: 5.seconds).perform_later('project_rank_service', self.id)
end
end
@ -458,6 +458,10 @@ class Project < ApplicationRecord
$redis_cache.hdel("issue_cache_delete_count", self.id)
end
def open_portrait
EduSetting.get("open_portrait_projects").present? ? EduSetting.get("open_portrait_projects").split(",").include?(self.id.to_s) : false
end
def self.mindspore_contributors
cache_result = $redis_cache.get("ProjectMindsporeContributors")
if cache_result.nil?

View File

@ -833,7 +833,11 @@ class User < Owner
end
def admin_or_business?
admin? || business?
admin? || business?
end
def admin_or_glcc_admin?
admin? || glcc_admin?
end
def self.generate_login(prefix)

View File

@ -13,11 +13,8 @@ class Admins::GlccExamineMaterial < ApplicationQuery
materials = GlccMediumTermExamineMaterial.all
# term
term = params[:term] || [1,2]
if term.present?
materials = materials.where(term: term)
end
#year
materials = materials.where(term: params[:term]) if params[:term].present?
#year
year = if params[:date]
params[:date][:year]
end

View File

@ -38,7 +38,7 @@ class Projects::ListQuery < ApplicationQuery
end
def main_collection
collection = Project.visible
collection = Project.visible.where(status: 1)
# 增加私有组织中项目过滤
collection = collection.joins("left join organization_extensions on organization_extensions.organization_id = projects.user_id")
.where("organization_extensions.visibility is null or organization_extensions.visibility in (0,1)")

View File

@ -31,7 +31,7 @@ class Admins::UpdateUserService < ApplicationService
private
def user_attributes
params.slice(*%i[lastname nickname mail phone admin business is_test login
params.slice(*%i[lastname nickname mail phone admin business glcc_admin is_test login
professional_certification authentication is_shixun_marker website_permission])
end

View File

@ -31,6 +31,61 @@ class Cache::V2::PlatformStatisticService < ApplicationService
"v2-platform-statistic"
end
# 平台最高关注数
def max_watcher_count_key
"max-watcher-count"
end
# 平台最高点赞数
def max_praise_count_key
"max-praise-count"
end
# 平台最高fork数
def max_fork_count_key
"max-fork-count"
end
# 平台最高pr数
def max_pullrequest_count_key
"max-pullrequest-count"
end
# 平台最高issue数
def max_issue_count_key
"max-issue-count"
end
# 平台最高commit数
def max_commit_count_key
"max-commit-count"
end
# 平台最高仓库人数
def max_member_count_key
"max-member-count"
end
# 平台近一个月新增成员最大值
def max_recent_one_month_member_count_key
"max-recent-one-month-member-count"
end
# 平台近一个月合并请求最大值
def max_recent_one_month_pullrequest_count_key
"max-recent-one-month-pullrequest-count"
end
# 平台近一个月issue最大值
def max_recent_one_month_issue_count_key
"max-recent-one-month-issue-count"
end
# 平台近一个月commit最大值
def max_recent_one_month_commit_count_key
"max-recent-one-month-commit-count"
end
def follow_count_key
"follow-count"
end
@ -136,6 +191,61 @@ class Cache::V2::PlatformStatisticService < ApplicationService
$redis_cache.hgetall(platform_statistic_key)
end
def reset_platform_max_watcher_count
max_watcher = Watcher.where(watchable_type:"Project").group(:watchable_type, :watchable_id).count.sort_by{|i|i[1]}.last || []
$redis_cache.hset(platform_statistic_key, max_watcher_count_key, max_watcher[1].nil? ? 0 : max_watcher[1])
end
def reset_platform_max_praise_count
max_praise = PraiseTread.where(praise_tread_object_type: "Project").group(:praise_tread_object_type, :praise_tread_object_id).count.sort_by{|i|i[1]}.last || []
$redis_cache.hset(platform_statistic_key, max_praise_count_key, max_praise[1].nil? ? 0 : max_praise[1])
end
def reset_platform_max_fork_count
max_fork = ForkUser.group(:project_id).count.sort_by{|i|i[1]}.last || []
$redis_cache.hset(platform_statistic_key, max_fork_count_key, max_fork[1].nil? ? 0 : max_fork[1])
end
def reset_platform_max_pullrequest_count
max_pullrequest = PullRequest.group(:project_id).count.sort_by{|i|i[1]}.last || []
$redis_cache.hset(platform_statistic_key, max_pullrequest_count_key, max_pullrequest[1].nil? ? 0 : max_pullrequest[1])
end
def reset_platform_max_issue_count
max_issue = Issue.where.not(project_id: 0).issue_issue.group(:project_id).count.sort_by{|i|i[1]}.last || []
$redis_cache.hset(platform_statistic_key, max_issue_count_key, max_issue[1].nil? ? 0 : max_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])
end
def reset_platform_max_member_count
max_member = Member.where.not(project_id: [0,-1]).group(:project_id).count.sort_by{|i|i[1]}.last || []
$redis_cache.hset(platform_statistic_key, max_member_count_key, max_member[1].nil? ? 0 : max_member[1])
end
def reset_platform_max_recent_one_month_member_count
max_recent_one_month_member = Member.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_member_count_key, max_recent_one_month_member[1].nil? ? 0 : max_recent_one_month_member[1])
end
def reset_platform_max_recent_one_month_pullrequest_count
max_recent_one_month_pullrequest = PullRequest.where("created_at > ?", Time.now - 30.days).group(:project_id).count.sort_by{|i|i[1]}.last || []
$redis_cache.hset(platform_statistic_key, max_recent_one_month_pullrequest_count_key, max_recent_one_month_pullrequest[1].nil? ? 0 : max_recent_one_month_pullrequest[1])
end
def reset_platform_max_recent_one_month_issue_count
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
def reset_platform_max_recent_one_month_commit_count
max_recent_one_month_commit = CommitLog.joins(:project).merge(Project.common).where("created_at > ?", Time.now - 30.days).group(:project_id).count.sort_by{|i|i[1]}.last || []
$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_follow_count
$redis_cache.hset(platform_statistic_key, follow_count_key, Watcher.where(watchable_type: 'User').count)
end
@ -178,6 +288,17 @@ class Cache::V2::PlatformStatisticService < ApplicationService
reset_platform_project_praise_count
reset_platform_project_watcher_count
reset_platform_pullrequest_count
reset_platform_max_watcher_count
reset_platform_max_praise_count
reset_platform_max_fork_count
reset_platform_max_pullrequest_count
reset_platform_max_issue_count
reset_platform_max_commit_count
reset_platform_max_member_count
reset_platform_max_recent_one_month_member_count
reset_platform_max_recent_one_month_pullrequest_count
reset_platform_max_recent_one_month_issue_count
reset_platform_max_recent_one_month_commit_count
$redis_cache.hgetall(platform_statistic_key)
end

View File

@ -1,9 +1,10 @@
class Gitea::Repository::DeleteService < Gitea::ClientService
attr_reader :user, :repo_name
attr_reader :user, :repo_name, :token
def initialize(user, repo_name)
def initialize(user, repo_name, token=nil)
@user = user
@repo_name = repo_name
@token = token
end
def call
@ -13,7 +14,7 @@ class Gitea::Repository::DeleteService < Gitea::ClientService
private
def params
Hash.new.merge(token: user.gitea_token)
Hash.new.merge(token: token)
end
def url

View File

@ -38,18 +38,27 @@ class Repositories::CreateService < ApplicationService
private
def create_gitea_repository
if project.owner.is_a?(User)
# @gitea_repository = Gitea::Repository::CreateService.new(user.gitea_token, gitea_repository_params).call
@gitea_repository = $gitea_client.post_user_repos({query: {token: user.gitea_token}, body: gitea_repository_params.to_json})
elsif project.owner.is_a?(Organization)
# @gitea_repository = Gitea::Organization::Repository::CreateService.call(user.gitea_token, project.owner.login, gitea_repository_params)
@gitea_repository = $gitea_client.post_orgs_repos_by_org(project.owner.login, {query: {token: user.gitea_token}, body: gitea_repository_params.to_json})
begin
@gitea_repository = $gitea_client.get_repos_by_owner_repo(project.owner.login, params[:identifier])
rescue Gitea::Api::ServerError => e
if e.http_code.to_i == 404
if project.owner.is_a?(User)
# @gitea_repository = Gitea::Repository::CreateService.new(user.gitea_token, gitea_repository_params).call
@gitea_repository = $gitea_client.post_user_repos({query: {token: user.gitea_token}, body: gitea_repository_params.to_json})
elsif project.owner.is_a?(Organization)
# @gitea_repository = Gitea::Organization::Repository::CreateService.call(user.gitea_token, project.owner.login, gitea_repository_params)
@gitea_repository = $gitea_client.post_orgs_repos_by_org(project.owner.login, {query: {token: user.gitea_token}, body: gitea_repository_params.to_json})
end
else
raise "服务器错误,请联系系统管理员!"
end
end
end
def sync_project
if gitea_repository
project.update_columns(
is_public: !gitea_repository["private"],
gpid: gitea_repository["id"],
identifier: repository.identifier,
default_branch: gitea_repository["default_branch"],
@ -58,7 +67,7 @@ class Repositories::CreateService < ApplicationService
end
def sync_repository
repository.update_columns(url: remote_repository_url,) if gitea_repository
repository.update_columns(url: remote_repository_url, hidden: gitea_repository["private"]) if gitea_repository
end
def remote_repository_url

View File

@ -2,7 +2,7 @@
<%= form_tag(admins_glcc_pr_check_index_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
<div class="form-group mr-2">
<label for="status">考核选项:</label>
<% status_options = [['中期考核',1], ['结项考核', 2]] %>
<% status_options = [['全部',''],['中期考核',1], ['结项考核', 2]] %>
<%= select_tag(:term, options_for_select(status_options), class: 'form-control') %>
</div>
@ -22,7 +22,7 @@
<%= form_tag(send_mail_admins_glcc_pr_check_index_path, method: :post, class: 'form-inline search-form flex-1', remote: true) do %>
<div class="form-group mr-2">
<label for="status">  请选择考核选项:</label>
<% status_options = [['中期考核',1], ['结项考核', 2]] %>
<% status_options = [['全部',''],['中期考核',1], ['结项考核', 2]] %>
<%= select_tag(:term, options_for_select(status_options), class: 'form-control') %>
</div>

View File

@ -16,7 +16,7 @@
<tbody>
<% statistics.each_with_index do |item, index| %>
<tr class="">
<td><%= index + 1%></td>
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td>
<a target="_blank" href="<%= "/#{item&.project&.owner&.login}/#{item&.project&.identifier}"%>">
<%= "#{item&.project&.owner&.real_name}/#{item&.project&.name}" %>
@ -34,4 +34,6 @@
</tr>
<% end %>
</tbody>
</table>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: statistics } %>

View File

@ -13,85 +13,85 @@
<!-- Sidebar Links -->
<ul class="list-unstyled components">
<li><%= sidebar_item(admins_path, '数据概览', icon: 'dashboard', controller: 'admins-dashboards') %></li>
<li><%= sidebar_item(admins_path, '数据概览', icon: 'dashboard', controller: 'admins-dashboards', has_permission: current_user.admin?) %></li>
<li>
<%= sidebar_item_group('#user-submenu', '用户', icon: 'user') do %>
<li><%= sidebar_item(admins_users_path, '用户列表', icon: 'user', controller: 'admins-users') %></li>
<li><%= sidebar_item(admins_organizations_path, '组织列表', icon: 'user', controller: 'admins-organizations') %></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('#setting-submenu', '用户支持', icon: 'cogs') do %>
<li><%= sidebar_item(admins_faqs_path, 'FAQ', icon: 'question-circle', controller: 'admins-faqs') %></li>
<li><%= sidebar_item(admins_nps_path, 'NPS用户调研', icon: 'question-circle', controller: 'admins-nps') %></li>
<li><%= sidebar_item(admins_feedbacks_path, '用户反馈', icon: 'question-circle', controller: 'admins-feedbacks') %></li>
<li><%= sidebar_item(admins_system_notifications_path, '系统公告配置', icon: 'bell', controller: 'admins-system_notifications') %></li>
<%= sidebar_item_group('#setting-submenu', '用户支持', icon: 'cogs', has_permission: current_user.admin? || current_user.business?) do %>
<li><%= sidebar_item(admins_faqs_path, 'FAQ', icon: 'question-circle', controller: 'admins-faqs', has_permission: current_user.admin? || current_user.business?) %></li>
<li><%= sidebar_item(admins_nps_path, 'NPS用户调研', icon: 'question-circle', controller: 'admins-nps', has_permission: current_user.admin? || current_user.business?) %></li>
<li><%= sidebar_item(admins_feedbacks_path, '用户反馈', icon: 'question-circle', controller: 'admins-feedbacks', has_permission: current_user.admin? || current_user.business?) %></li>
<li><%= sidebar_item(admins_system_notifications_path, '系统公告配置', icon: 'bell', controller: 'admins-system_notifications', has_permission: current_user.admin? || current_user.business?) %></li>
<% end %>
</li>
<li><%= sidebar_item(admins_laboratories_path, '导航栏配置', icon: 'cloud', controller: 'admins-laboratories') %></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') do %>
<li><%= sidebar_item(admins_sites_path, 'setting接口配置', icon: 'deaf', controller: 'admins-sites') %></li>
<li><%= sidebar_item(admins_edu_settings_path, '全局变量配置', icon: 'pencil-square', controller: 'admins-edu_settings') %></li>
<li><%= sidebar_item(admins_message_templates_path, '消息模版配置', icon: 'folder', controller: 'admins-message_templates') %></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>
<% end %>
</li>
<li><%= sidebar_item(admins_reversed_keywords_path, '禁用词管理', icon: 'key', controller: 'admins-reversed_keywords') %></li>
<li><%= sidebar_item(admins_reversed_keywords_path, '禁用词管理', icon: 'key', controller: 'admins-reversed_keywords', has_permission: current_user.admin?) %></li>
<li>
<%= sidebar_item_group('#projects-submenu', '开源项目', icon: 'database') do %>
<li><%= sidebar_item(admins_projects_path, '项目列表', icon: 'database', controller: 'admins-projects') %></li>
<li><%= sidebar_item(admins_project_languages_path, '项目语言', icon: 'language', controller: 'admins-project_languages') %></li>
<li><%= sidebar_item(admins_project_categories_path, '分类列表', icon: 'sitemap', controller: 'admins-project_categories') %></li>
<li><%= sidebar_item(admins_project_licenses_path, '开源许可证', icon: 'file-text-o', controller: 'admins-project_licenses') %></li>
<li><%= sidebar_item(admins_project_ignores_path, '忽略文件', icon: 'git', controller: 'admins-project_ignores') %></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_group('#setting-index', '首页配置', icon: 'file') do %>
<li><%= sidebar_item(admins_topic_banners_path, 'banner管理', icon: 'image', controller: 'admins-topic-banners') %></li>
<li><%= sidebar_item(admins_topic_cards_path, '卡片管理', icon: 'archive', controller: 'admins-topic-cards') %></li>
<li><%= sidebar_item(admins_topic_activity_forums_path, '平台动态管理', icon: 'bell', controller: 'admins-topic-activity_forums') %></li>
<li><%= sidebar_item(admins_topic_excellent_projects_path, '优秀仓库管理', icon: 'git', controller: 'admins-topic-excellent_projects') %></li>
<li><%= sidebar_item(admins_topic_pinned_forums_path, '精选文章管理', icon: 'edit', controller: 'admins-topic-pinned_forums') %></li>
<li><%= sidebar_item(admins_topic_experience_forums_path, '经验分享管理', icon: 'edit', controller: 'admins-topic-experience_forums') %></li>
<li><%= sidebar_item(admins_topic_cooperators_path, '合作伙伴管理', icon: 'user', controller: 'admins-topic-cooperators') %></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_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>
<li><%= sidebar_item(admins_topic_experience_forums_path, '经验分享管理', icon: 'edit', controller: 'admins-topic-experience_forums', has_permission: current_user.admin? || current_user.business?) %></li>
<li><%= sidebar_item(admins_topic_cooperators_path, '合作伙伴管理', icon: 'user', controller: 'admins-topic-cooperators', has_permission: current_user.admin? || current_user.business?) %></li>
<% end %>
</li>
<li>
<%= sidebar_item_group('#setting-glcc', 'GLCC配置', icon: 'fire') do %>
<li><%= sidebar_item(admins_topic_glcc_news_index_path, '新闻稿管理', icon: 'edit', controller: 'admins-topic-glcc_news') %></li>
<%= sidebar_item_group('#setting-glcc', 'GLCC配置', icon: 'fire', has_permission: current_user.admin? || current_user.glcc_admin?) do %>
<li><%= sidebar_item(admins_topic_glcc_news_index_path, '新闻稿管理', icon: 'edit', controller: 'admins-topic-glcc_news', has_permission: current_user.admin? || current_user.glcc_admin?) %></li>
<li>
<% if EduSetting.get("glcc_apply_informations_admin_url")%>
<%= sidebar_item(EduSetting.get("glcc_apply_informations_admin_url"), '报名列表', icon: 'user', controller: 'root') %>
<%= sidebar_item(EduSetting.get("glcc_apply_informations_admin_url"), '报名列表', icon: 'user', controller: 'root', has_permission: current_user.admin? || current_user.glcc_admin?) %>
<% end %>
</li>
<li><%= sidebar_item(admins_glcc_pr_check_index_path, '考核PR检测', icon: 'edit', controller: 'admins-glcc_pr_check') %></li>
<li><%= sidebar_item(admins_glcc_pr_check_index_path, '考核PR检测', icon: 'edit', controller: 'admins-glcc_pr_check', has_permission: current_user.admin? || current_user.glcc_admin?) %></li>
<% end %>
</li>
<li>
<%= sidebar_item_group('#pages-submenu', '个人站点管理', icon: 'cogs') do %>
<li><%= sidebar_item(admins_identity_verifications_path, '身份审核列表', icon: 'user', controller: 'admins-identity_verifications') %></li>
<li><%= sidebar_item(admins_site_pages_path, '用户站点列表', icon: 'sitemap', controller: 'admins-site_pages') %></li>
<li><%= sidebar_item(admins_page_themes_path, '站点主题配置', icon: 'cogs', controller: 'admins-page_themes') %></li>
<%= sidebar_item_group('#pages-submenu', '个人站点管理', icon: 'cogs', has_permission: current_user.admin? || current_user.business?) do %>
<li><%= sidebar_item(admins_identity_verifications_path, '身份审核列表', icon: 'user', controller: 'admins-identity_verifications', has_permission: current_user.admin? || current_user.business?) %></li>
<li><%= sidebar_item(admins_site_pages_path, '用户站点列表', icon: 'sitemap', controller: 'admins-site_pages', has_permission: current_user.admin?) %></li>
<li><%= sidebar_item(admins_page_themes_path, '站点主题配置', icon: 'cogs', controller: 'admins-page_themes', has_permission: current_user.admin?) %></li>
<% end %>
</li>
<li>
<%= sidebar_item_group('#rank-submenu', '活跃度排行', icon: 'calendar') do %>
<li><%= sidebar_item(admins_users_rank_index_path, '用户活跃度排行', icon: 'user', controller: 'admins-users_rank') %></li>
<li><%= sidebar_item(admins_projects_rank_index_path, '项目活跃度排行', icon: 'database', controller: 'admins-projects_rank') %></li>
<li><%= sidebar_item(admins_issues_rank_index_path, '疑修活跃度排行', icon: 'calendar', controller: 'admins-issues_rank') %></li>
<%= sidebar_item_group('#rank-submenu', '活跃度排行', icon: 'calendar', has_permission: current_user.admin?) do %>
<li><%= sidebar_item(admins_users_rank_index_path, '用户活跃度排行', icon: 'user', controller: 'admins-users_rank', has_permission: current_user.admin?) %></li>
<li><%= sidebar_item(admins_projects_rank_index_path, '项目活跃度排行', icon: 'database', controller: 'admins-projects_rank', has_permission: current_user.admin?) %></li>
<li><%= sidebar_item(admins_issues_rank_index_path, '疑修活跃度排行', icon: 'calendar', controller: 'admins-issues_rank', has_permission: current_user.admin?) %></li>
<% end %>
</li>
<%= render_admin_statistics_item %>
<%= render_admin_statistics_item if current_user.admin? || current_user.business? %>
<li>
<%= sidebar_item('/admins/sidekiq', '定时任务', icon: 'bell', controller: 'root') %>
<%= sidebar_item('/admins/sidekiq', '定时任务', icon: 'bell', controller: 'root', has_permission: current_user.admin?) %>
</li>
<li><%= sidebar_item('/', '返回主站', icon: 'sign-out', controller: 'root') %></li>
<li><%= sidebar_item('/', '返回主站', icon: 'sign-out', controller: 'root', has_permission: current_user.admin?) %></li>
</ul>
</nav>

View File

@ -89,6 +89,8 @@
<%= f.label :role, label: '角色' %>
<div class="d-flex">
<%= f.input :admin, as: :boolean, label: '管理员', checked_value: 1, unchecked_value: 0 %>
<%= f.input :business, as: :boolean, label: '运营人员', wrapper_html: { class: 'ml-3' }, checked_value: 1, unchecked_value: 0 %>
<%= f.input :glcc_admin, as: :boolean, label: 'GLCC管理员', wrapper_html: { class: 'ml-3' }, checked_value: 1, unchecked_value: 0 %>
</div>
</div>
<% end %>

View File

@ -12,6 +12,7 @@ if tag.present? && tag.is_a?(Hash)
end
json.time_ago time_from_now(tag['tagger']['date'].to_time)
json.created_at_unix tag['tagger']['date'].to_time.to_i
json.created_time tag['tagger']['date'].to_time
json.message tag['message']
json.commit do
json.sha tag['commit']['sha']

View File

@ -13,6 +13,7 @@ json.projects @projects do |project|
json.mirror_url project.repository&.mirror_url
json.type project&.numerical_for_project_type
json.last_update_time render_unix_time(project.updated_on)
json.full_last_update_time project.updated_on
json.time_ago time_from_now(project.updated_on)
json.forked_from_project_id project.forked_from_project_id
json.open_devops project.open_devops?

View File

@ -32,6 +32,7 @@ json.issues do
json.id issue.id
json.name issue.subject
json.pr_time time_from_now(pr.status == 1 ? pr.updated_at : issue.updated_on)
json.pr_full_time pr.status == 1 ? pr.updated_at : issue.updated_on
json.assign_user_name issue.get_assign_user.try(:show_real_name)
json.assign_user_login issue.get_assign_user.try(:login)
json.author_name issue.user.try(:show_real_name)

View File

@ -1,4 +1,3 @@
json.empty @result[:repo]["empty"]
json.content @project.content
json.website @project.website
json.lesson_url @project.lesson_url
@ -48,6 +47,7 @@ json.fork_info do
end
end
if @result[:repo]
json.empty @result[:repo]["empty"]
json.size replace_bytes_to_b(number_to_human_size(@result[:repo]['size'].to_i*1024))
json.ssh_url @result[:repo]['ssh_url']
json.clone_url @project.educoder? ? "#{Rails.application.config_for(:configuration)['educoder']['git_site']}/#{@project&.project_educoder&.repo_name}.git" : @result[:repo]['clone_url']
@ -56,6 +56,7 @@ if @result[:repo]
json.full_name @result[:repo]['full_name']
json.private @result[:repo]['private']
else
json.empty true
json.size 0
json.ssh_url nil
json.clone_url nil

View File

@ -10,6 +10,7 @@ json.tags @tags do |tag|
end
json.time_ago time_from_now(tag['tagger']['date'].to_time)
json.created_at_unix tag['tagger']['date'].to_time.to_i
json.created_time tag['tagger']['date'].to_time
json.message tag['message']
json.commit do
json.sha tag['commit']['sha']

View File

@ -31,7 +31,7 @@ json.setting do
json.name default_setting.name
json.nav_logo_url default_setting.nav_logo_url&.[](1..-1)
json.login_logo_url default_setting.login_logo_url&.[](1..-1)
json.tab_logo_url default_setting.tab_logo_url&.[](1..-1)
json.tab_logo_url default_setting.tab_logo_url.present? ? default_setting.tab_logo_url&.[](1..-1) : "favicon.ico"
json.site_page_deploy_domain @deploy_domain
json.subject_banner_url default_setting.subject_banner_url&.[](1..-1)

View File

@ -287,6 +287,7 @@ Rails.application.routes.draw do
post :following
post :unfollow
get :get_user_info
get :get_user_info_by_login
get :attachment_show
get :html_show
get :get_navigation_info

View File

@ -123,6 +123,7 @@ defaults format: :json do
# projects文件夹下的
scope module: :projects do
resources :portrait, only: [:index]
resources :sync_repositories, only: [:create, :index] do
collection do
post :update_info

View File

@ -16,4 +16,11 @@ create_daily_project_statistics:
daily_platform_statistics:
cron: "0 1 * * *"
class: "DailyPlatformStatisticsJob"
queue: default
queue: default
cache_async_reset:
cron: "0 2 * * *"
class: "CacheAsyncResetJob"
queue: cache
args:
- "platform_statistic_service"

View File

@ -0,0 +1,5 @@
class AddGlccAdminFieldToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :glcc_admin, :boolean, default: false
end
end