white list for glcc pr check

This commit is contained in:
呱呱呱 2023-08-09 14:30:23 +08:00
parent e3b3dacde7
commit 6c44ecae2d
4 changed files with 38 additions and 6 deletions

View File

@ -11,6 +11,20 @@ class SettingsController < ApplicationController
get_top_system_notification
end
def check_url
url = params[:url]
task_id = params[:task]
term = params[:term]
return normal_status(-1, "缺少url参数") unless url.present?
return normal_status(-1, "缺少term参数") unless term.present?
return normal_status(-1, "缺少task参数") unless task_id.present?
glcc_mate = GlccMediumTermExamineMaterial.new(code_or_pr_url: url, task_id: task_id, term: term, created_on:Time.now)
state = glcc_mate.check_pr_url
errors = glcc_mate.gennerate_content(state)
render_ok({ state:state, state_html: errors})
end
private
def get_navbar
@navbar = default_laboratory.navbar

View File

@ -40,10 +40,25 @@ class GlccMediumTermExamineMaterial < ActiveRecord::Base
unless pr.present?
state << 3
end
if white_list && term == 1 #特殊处理 白名单的中期考核不处理 中期考核后去掉
state = []
end
state
end
def white_list
# 全局设置白名单 key
key = "glcc_white_task_#{self.created_on.year}"
white_task = EduSetting.find_by_name(key)
if white_task
task_ids = white_task.value.split(",")
task_ids.map(&:to_i).include?(self.task_id)
else
false
end
end
def send_mail
gcs = glcc_student
mail = gcs.mail
@ -52,11 +67,7 @@ class GlccMediumTermExamineMaterial < ActiveRecord::Base
state = check_pr_url
return unless state.present?
title = "2023年GitLink确实开源GLCC开源夏令营#{term == 1 ? "中期考核" : "结项考核"}提醒"
content = ""
state.map{|e|
content = content + number_to_content(e)
}
puts content
content = gennerate_content(state)
UserMailer.glcc_pr_check_email(mail,title, gcs.student_name, content).deliver_now
end
@ -65,6 +76,10 @@ class GlccMediumTermExamineMaterial < ActiveRecord::Base
mail = gcs.mail
return "数据异常PR连接为空" if mail.nil? || code_or_pr_url.nil?
state = check_pr_url
gennerate_content(state)
end
def gennerate_content(state)
content = ""
state.map{|e|
content = content + number_to_content(e)

View File

@ -6,7 +6,8 @@
<th width="13%">邮件地址</th>
<th width="6%">视频地址</th>
<th width="6%">PR地址</th>
<th width="14%">考核阶段</th>
<th width="5%">考核阶段</th>
<th width="5%">白名单</th>
<th width="14%">检测状态</th>
<th width="14%">提交时间</th></th>
</tr>
@ -21,6 +22,7 @@
<td><a target="_blank" href="<%= user.defence_video_url %>"> 查看视频 </a></></td>
<td><a target="_blank" href="<%= user.code_or_pr_url %>"> 查看PR </a></></td>
<td><%= user.term == 1 ? "中期考核" : "结项考核"%></td>
<td><%= user.white_list ? "是":"否" %></td>
<td><%= user.state_to_html.html_safe %></td>
<td><%= user.created_on.strftime("%Y-%m-%d %H:%M")%></td>
</tr>

View File

@ -19,6 +19,7 @@ Rails.application.routes.draw do
get 'attachments/entries/get_file', to: 'attachments#get_file'
get 'attachments/download/:id', to: 'attachments#show'
get 'attachments/download/:id/:filename', to: 'attachments#show'
get 'check_pr_url',to: "settings#check_url"
# get 'auth/qq/callback', to: 'oauth/qq#create'
get 'auth/failure', to: 'oauth/base#auth_failure'