From 91ca657a62ec3e9a6c6139052b7e44042037fa2d Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 10 Feb 2020 12:57:34 +0800
Subject: [PATCH 1/7] =?UTF-8?q?=E7=9B=B4=E6=92=AD=E5=88=97=E8=A1=A8?=
=?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/live_links_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/live_links_controller.rb b/app/controllers/live_links_controller.rb
index ea7155948..29233e37b 100644
--- a/app/controllers/live_links_controller.rb
+++ b/app/controllers/live_links_controller.rb
@@ -9,7 +9,7 @@ class LiveLinksController < ApplicationController
order_str = "on_status desc,id desc"
@total_count = lives.size
@my_live_id = @course.live_links.find_by(user_id: current_user.id)&.id
- order_str = "#{@my_live_id} desc, #{order_str}" if @my_live_id.present?
+ order_str = "live_links.id = #{@my_live_id} desc, #{order_str}" if @my_live_id.present?
lives = lives.order("#{order_str}")
@lives = paginate lives.includes(user: :user_extension)
end
From 7385a912e9a5d77cfaf1bb566f733e5ac7d72204 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Mon, 10 Feb 2020 13:10:14 +0800
Subject: [PATCH 2/7] 1
---
app/controllers/concerns/controller_rescue_handler.rb | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/app/controllers/concerns/controller_rescue_handler.rb b/app/controllers/concerns/controller_rescue_handler.rb
index 03d51e1b4..dde6c4a8d 100644
--- a/app/controllers/concerns/controller_rescue_handler.rb
+++ b/app/controllers/concerns/controller_rescue_handler.rb
@@ -6,12 +6,17 @@ module ControllerRescueHandler
Util.logger_error e
render json: {status: -1, message: "接口异常"}
end
+ rescue_from Mysql2::Error do |e|
+ Util.logger_error e
+ render json: {status: -1, message: "接口数据异常"}
+ end
# rescue_from ActionView::MissingTemplate, with: :object_not_found
# rescue_from ActiveRecord::RecordNotFound, with: :object_not_found
rescue_from Educoder::TipException, with: :tip_show
rescue_from ::ActionView::MissingTemplate, with: :missing_template
rescue_from ActiveRecord::RecordNotFound, with: :object_not_found
rescue_from ActionController::ParameterMissing, with: :render_parameter_missing
+
# form validation error
rescue_from ActiveModel::ValidationError do |ex|
render_error(ex.model.errors.full_messages.join(','))
From a4376c9aa3622b95f62a1bdb1df5c386f64e6215 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 10 Feb 2020 13:24:13 +0800
Subject: [PATCH 3/7] =?UTF-8?q?=E5=88=A0=E9=99=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/live_links_controller.rb | 9 ++++++---
config/routes.rb | 2 +-
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/app/controllers/live_links_controller.rb b/app/controllers/live_links_controller.rb
index 29233e37b..f4b49d4aa 100644
--- a/app/controllers/live_links_controller.rb
+++ b/app/controllers/live_links_controller.rb
@@ -2,7 +2,7 @@ class LiveLinksController < ApplicationController
before_action :require_login
before_action :find_course, only: [:index, :create]
before_action :user_course_identity, :teacher_allowed, only: [:create]
- before_action :edit_auth, only: [:edit, :update]
+ before_action :edit_auth, only: [:edit, :update, :destroy]
def index
lives = @course.live_links
@@ -34,8 +34,6 @@ class LiveLinksController < ApplicationController
# 开启时发送消息,关闭直播时删除对应的消息
if params[:on_status].to_i == 1
LivePublishJob.perform_later(current_live.id)
- else
- current_live.tidings.destroy_all
end
end
else
@@ -44,6 +42,11 @@ class LiveLinksController < ApplicationController
render_ok
end
+ def destroy
+ current_live.destroy!
+ render_ok
+ end
+
private
def create_params
diff --git a/config/routes.rb b/config/routes.rb
index f0c91e8f9..63a6e4494 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -550,7 +550,7 @@ Rails.application.routes.draw do
end
end
- resources :live_links, only: [:index, :update, :create, :edit], shallow: true
+ resources :live_links, only: [:index, :update, :create, :edit, :destroy], shallow: true
resources :homework_commons, shallow: true do
From 811bcf2ee57e1a4ab0f06933141401fe15daca10 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 10 Feb 2020 14:42:25 +0800
Subject: [PATCH 4/7] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/tidings_controller.rb | 1 +
app/models/student_work.rb | 1 +
app/views/student_works/shixun_work_report.json.jbuilder | 1 +
3 files changed, 3 insertions(+)
diff --git a/app/controllers/tidings_controller.rb b/app/controllers/tidings_controller.rb
index 5acffcb16..0a28b85e4 100644
--- a/app/controllers/tidings_controller.rb
+++ b/app/controllers/tidings_controller.rb
@@ -19,6 +19,7 @@ class TidingsController < ApplicationController
end
tidings = tidings.where(tiding_type: tiding_types) if tiding_types.present?
+ # coures_message_id = current_user.manage_courses.not_deleted.course_messages.join_course_requests.unhandled
tidings = tidings.where(container_type: 'JoinCourse') if params[:type] == 'course_apply'
@course_apply_count = tidings.where("created_at > '#{@onclick_time}'").where(container_type: 'JoinCourse').count
diff --git a/app/models/student_work.rb b/app/models/student_work.rb
index f8f3bee99..384a75da1 100644
--- a/app/models/student_work.rb
+++ b/app/models/student_work.rb
@@ -111,6 +111,7 @@ class StudentWork < ApplicationRecord
# 作品总体评价
def overall_appraisal
+ return nil if work_status == 0
case (self.work_score.to_f / homework_common.total_score).round(2)
when (0.90..1.00)
'优秀'
diff --git a/app/views/student_works/shixun_work_report.json.jbuilder b/app/views/student_works/shixun_work_report.json.jbuilder
index 068151856..bd618c2d4 100644
--- a/app/views/student_works/shixun_work_report.json.jbuilder
+++ b/app/views/student_works/shixun_work_report.json.jbuilder
@@ -4,6 +4,7 @@ json.course_name @course.name
json.work_id @work.id
json.work_efficiency @homework.work_efficiency
json.has_commit @work.myshixun.present?
+json.work_status @work.work_status
if @shixun
json.shixun_name @shixun.name
# 总体评价
From d667d82e5c9b3a5c8f032c3ecfb16c0c0e9aa1f1 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 10 Feb 2020 15:06:17 +0800
Subject: [PATCH 5/7] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AE=9E=E8=AE=AD?=
=?UTF-8?q?=E6=8A=A5=E5=91=8A=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/student_work.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/models/student_work.rb b/app/models/student_work.rb
index 384a75da1..a4ae63f04 100644
--- a/app/models/student_work.rb
+++ b/app/models/student_work.rb
@@ -111,7 +111,7 @@ class StudentWork < ApplicationRecord
# 作品总体评价
def overall_appraisal
- return nil if work_status == 0
+ return "--" if work_status == 0
case (self.work_score.to_f / homework_common.total_score).round(2)
when (0.90..1.00)
'优秀'
From c813b6fd44c0f2553fc97b91212c9638a473417b Mon Sep 17 00:00:00 2001
From: caicai8 <1149225589@qq.com>
Date: Mon, 10 Feb 2020 15:57:29 +0800
Subject: [PATCH 6/7] =?UTF-8?q?=E9=9C=80=E6=B1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../react/src/modules/courses/Video/Live.js | 7 +-
.../src/modules/courses/Video/LiveItem.js | 42 ++++-
.../src/modules/courses/Video/LiveNew.js | 144 +++++++++++++-----
.../react/src/modules/courses/Video/Video.js | 6 +-
.../src/modules/courses/Video/VideoIndex.js | 59 +++++--
.../react/src/modules/courses/Video/video.css | 8 +-
.../user/usersInfo/video/VideoUploadList.js | 40 ++---
7 files changed, 219 insertions(+), 87 deletions(-)
diff --git a/public/react/src/modules/courses/Video/Live.js b/public/react/src/modules/courses/Video/Live.js
index 71dced679..741339723 100644
--- a/public/react/src/modules/courses/Video/Live.js
+++ b/public/react/src/modules/courses/Video/Live.js
@@ -7,10 +7,10 @@ import './video.css';
class Live extends Component{
render(){
- const { liveData , lives , successFunc , pageSize , changePage } = this.props;
+ const { liveData , lives , successFunc , pageSize , changePage , page } = this.props;
return(
-
+
{
lives && lives.length > 0 ?
@@ -20,6 +20,7 @@ class Live extends Component{
lives.map((item,key)=>{
return(
pageSize &&
-
changePage(page,'live')}>
+
changePage(page,'live')}>
}
diff --git a/public/react/src/modules/courses/Video/LiveItem.js b/public/react/src/modules/courses/Video/LiveItem.js
index e709c41e6..ede737de4 100644
--- a/public/react/src/modules/courses/Video/LiveItem.js
+++ b/public/react/src/modules/courses/Video/LiveItem.js
@@ -1,6 +1,7 @@
import React,{ Component } from "react";
import { Switch } from 'antd';
import { getImageUrl } from 'educoder';
+import { WordsBtn } from 'educoder';
import axios from 'axios';
class LiveItem extends Component{
@@ -19,10 +20,33 @@ class LiveItem extends Component{
console.log(error);
})
}
+ deleteLive=(id)=>{
+ this.props.confirm({
+ content: '是否确认删除?',
+
+ onOk: () => {
+ const url = `/live_links/${id}.json`;
+ axios.delete(url).then(result=>{
+ if(result){
+ this.props.showNotification(`删除成功!`);
+ const { successFunc } = this.props;
+ successFunc && successFunc(1);
+ }
+ }).catch(error=>{
+ console.log(error);
+ })
+ },
+ onCancel() {
+ console.log('Cancel');
+ },
+ });
+
+ }
render(){
- const { item } = this.props;
+ const { key, item , setLiveId } = this.props;
+
return(
-
+
@@ -30,8 +54,8 @@ class LiveItem extends Component{
{item.on_status?'已开播':'未开播'}
{
- item.op_auth &&
-
this.changeStatus(flag,event,item.id)}>
+ item.op_auth ?
+
this.changeStatus(flag,event,item.id)}>:""
}
@@ -45,6 +69,16 @@ class LiveItem extends Component{
进入
}
+
+ 创建时间:{item.created_at}
+ {
+ item.op_auth ?
+
+ setLiveId(item.id)}>编辑
+ this.deleteLive(item.id)}>删除
+ :""
+ }
+
)
}
diff --git a/public/react/src/modules/courses/Video/LiveNew.js b/public/react/src/modules/courses/Video/LiveNew.js
index 0e3526b0f..68f784421 100644
--- a/public/react/src/modules/courses/Video/LiveNew.js
+++ b/public/react/src/modules/courses/Video/LiveNew.js
@@ -1,5 +1,5 @@
import React,{ Component } from "react";
-import { Modal , Form , Input } from 'antd';
+import { Modal , Form , Input , Spin } from 'antd';
import './video.css';
import axios from 'axios';
@@ -7,25 +7,83 @@ const { TextArea } = Input;
class LiveNew extends Component{
+ constructor(props){
+ super(props);
+ this.state={
+ isSpining:true
+ }
+ }
+
+ componentDidUpdate=(prevState)=>{
+ if(prevState && prevState.liveId !== this.props.liveId){
+ this.checkType();
+ }
+ }
+
+ checkType=()=>{
+ const { liveId } = this.props;
+
+ if(liveId){
+ const url =`/live_links/${liveId}/edit.json`;
+ axios.get(url).then(result=>{
+ if(result){
+ this.props.form.setFieldsValue({
+ url:result.data.url,
+ description:result.data.description,
+ })
+ }
+ })
+ }
+ this.setState({
+ isSpining:false
+ })
+ }
+
handleSubmit=()=>{
this.props.form.validateFields((err, values) => {
if(!err){
- const CourseId=this.props.match.params.coursesId;
- const url = `/courses/${CourseId}/live_links.json`;
- axios.post(url,{
- ...values
- }).then(result=>{
- if(result){
- this.props.showNotification("添加成功!");
- const { setliveVisibel } = this.props;
- setliveVisibel && setliveVisibel(false,true);
- }
- }).catch(error=>{
- console.log(error);
- })
+ const { liveId } = this.props;
+ if(liveId){
+ // 修改
+ this.updateFunc(liveId,values);
+ }else{
+ this.creatFunc(values);
+ }
}
})
}
+ // 修改
+ updateFunc=(id,values)=>{
+ const url = `/live_links/${id}.json`;
+ axios.put(url,{
+ ...values
+ }).then(result=>{
+ if(result){
+ this.props.showNotification("修改成功!");
+ const { setliveVisibel } = this.props;
+ setliveVisibel && setliveVisibel(false,true);
+ }
+ }).catch(error=>{
+ console.log(error);
+ })
+ }
+
+ // 新增
+ creatFunc=(values)=>{
+ const CourseId=this.props.match.params.coursesId;
+ const url = `/courses/${CourseId}/live_links.json`;
+ axios.post(url,{
+ ...values
+ }).then(result=>{
+ if(result){
+ this.props.showNotification("添加成功!");
+ const { setliveVisibel } = this.props;
+ setliveVisibel && setliveVisibel(false,true);
+ }
+ }).catch(error=>{
+ console.log(error);
+ })
+ }
validateDesc= (rule, value, callback) => {
if (value.length > 100) {
@@ -44,8 +102,10 @@ class LiveNew extends Component{
}
render(){
+ const { isSpining } = this.state;
const {getFieldDecorator} = this.props.form;
const { visible } = this.props;
+
return(
-
-
- {getFieldDecorator('url', {
- rules: [{required: true, message: "请输入第三方直播链接"}],
- })(
-
- )}
-
-
- {getFieldDecorator('description', {
- rules: [{
- validator: this.validateDesc,
- }],
- })(
-
- )}
-
-
- EduCoder推荐您使用腾讯课堂进行直播
- 操作指引
-
-
-
-
取消
-
确定
+
+
+
+ {getFieldDecorator('url', {
+ rules: [{required: true, message: "请输入第三方直播链接"}],
+ })(
+
+ )}
+
+
+ {getFieldDecorator('description', {
+ rules: [{
+ validator: this.validateDesc,
+ }],
+ })(
+
+ )}
+
+
+ EduCoder推荐您使用腾讯课堂进行直播
+ 操作指引
+
+
+
-
+
)
}
diff --git a/public/react/src/modules/courses/Video/Video.js b/public/react/src/modules/courses/Video/Video.js
index 189503be9..a9492a252 100644
--- a/public/react/src/modules/courses/Video/Video.js
+++ b/public/react/src/modules/courses/Video/Video.js
@@ -133,14 +133,14 @@ class Video extends Component{
}
render(){
- const { count , visible , videoVisible , videoId } = this.state;
+ const { visible , videoVisible , videoId } = this.state;
const CourseId=this.props.match.params.coursesId;
const login=this.props.user&&this.props.user.login;
const _inputValue = videoId && this.getCopyText(videoId.file_url, videoId.cover_url);
const { admin , is_teacher ,business} = this.props.user;
- const { videos , upload , uploadVideo , videoData , changePage ,pageSize } = this.props;
+ const { videos , upload , uploadVideo , videoData , changePage ,pageSize ,page } = this.props;
const operation = admin || business || (is_teacher && this.props.checkIfProfessionalCertification())
return(
@@ -209,7 +209,7 @@ class Video extends Component{
{
videoData && videoData.count > pageSize &&
-
changePage(page,'video')}>
+
changePage(page,'video')}>
}
diff --git a/public/react/src/modules/courses/Video/VideoIndex.js b/public/react/src/modules/courses/Video/VideoIndex.js
index ad76d6d5d..320c5c87a 100644
--- a/public/react/src/modules/courses/Video/VideoIndex.js
+++ b/public/react/src/modules/courses/Video/VideoIndex.js
@@ -28,6 +28,9 @@ class VideoIndex extends Component{
lives:undefined,
liveData:undefined,
+ my_liveId:undefined,
+ liveId:undefined,
+
liveVisible:false
}
}
@@ -50,6 +53,10 @@ class VideoIndex extends Component{
}
// 获取直播列表
getLiveList=(page)=>{
+ this.setState({
+ lives:undefined,
+ isSpining:true
+ })
const CourseId=this.props.match.params.coursesId;
const url = `/courses/${CourseId}/live_links.json`;
axios.get(url,{
@@ -62,7 +69,9 @@ class VideoIndex extends Component{
this.setState({
liveData:result.data,
lives:result.data.lives,
- isSpining:false
+ isSpining:false,
+ my_liveId:result.data.my_live_id,
+ liveId:result.data.my_live_id
})
}
}).catch(error=>{
@@ -111,13 +120,13 @@ class VideoIndex extends Component{
onEditVideo=(item)=>{
let videoId = {
- videoId: item.id,
- title: item.title
- }
- this.setState({
- videoId,
- })
- this.setVisible(true);
+ videoId: item.id,
+ title: item.title
+ }
+ this.setState({
+ videoId,
+ })
+ this.setVisible(true);
}
uploadVideo=(upload)=>{
this.setState({
@@ -132,7 +141,8 @@ class VideoIndex extends Component{
if (admin || business || (is_teacher && this.props.checkIfProfessionalCertification())) {
this.setState({
type:"video",
- upload:true
+ upload:true,
+ page:1
})
} else {
this.props.showProfessionalCertificationDialog();
@@ -140,12 +150,20 @@ class VideoIndex extends Component{
}
// 直播设置后回调的方法
- successFunc=()=>{
+ // successFunc=()=>{
+ // this.setState({
+ // type:"live",
+ // page:1
+ // })
+ // this.checkType("live",1);
+ // }
+ // 直播设置
+ liveSetting=()=>{
+ const { my_liveId } = this.state;
this.setState({
- type:"live",
- page:1
+ liveId:my_liveId
})
- this.checkType("live",1);
+ this.setliveVisibel(true);
}
//直播设置弹框
setliveVisibel=(flag,changetypeFlag)=>{
@@ -156,13 +174,21 @@ class VideoIndex extends Component{
this.checkType("live",1);
}
}
+ // 列表-编辑(修改传到编辑的id)
+ setLiveId=(id)=>{
+ this.setState({
+ liveId:id
+ })
+ this.setliveVisibel(true);
+ }
render(){
- const { videos , upload , videoData , type , liveData , lives , liveVisible , isSpining } = this.state;
+ const { videos , upload , videoData , type , liveData , lives , page , liveVisible , isSpining , liveId } = this.state;
const { admin , is_teacher } = this.props.user;
return(
上传视频
}
- this.setliveVisibel(true)}>直播设置
+ 直播设置
}
@@ -196,6 +222,7 @@ class VideoIndex extends Component{
diff --git a/public/react/src/modules/courses/Video/video.css b/public/react/src/modules/courses/Video/video.css
index e6186b640..c91e5477e 100644
--- a/public/react/src/modules/courses/Video/video.css
+++ b/public/react/src/modules/courses/Video/video.css
@@ -83,8 +83,8 @@
border-radius: 16px;
}
.labels.living{
- border:1px solid #FF5555;
- color: #FF5555;
+ border:1px solid #25C03B;
+ color: #25C03B;
}
.labels.lived{
border:1px solid #999999;
@@ -117,7 +117,9 @@
line-clamp: 2;
-webkit-box-orient: vertical;
}
-
+.switchStyle.ant-switch-checked{
+ background-color: #25C03B;
+}
.liveModal .ant-modal-body{
padding:20px;
}
diff --git a/public/react/src/modules/user/usersInfo/video/VideoUploadList.js b/public/react/src/modules/user/usersInfo/video/VideoUploadList.js
index 0ca13731b..6f6286727 100644
--- a/public/react/src/modules/user/usersInfo/video/VideoUploadList.js
+++ b/public/react/src/modules/user/usersInfo/video/VideoUploadList.js
@@ -4,7 +4,7 @@ import { getUrl2, isDev, CBreadcrumb, ActionBtn, ThemeContext } from 'educoder'
import axios from 'axios'
import VideoUpload from './VideoUpload'
-import { Button } from 'antd'
+import { Button, Spin } from 'antd'
import { getUploader } from './AliyunUploaderManager'
import { reducer, initialState } from './VideoReducer'
@@ -23,7 +23,8 @@ function VideoUploadList (props) {
// const [videos, setvideos] = useState([]);
const [state, dispatch] = useReducer(reducer, initialState);
const theme = useContext(ThemeContext)
- const [couldRouteNav, setCouldRouteNav] = useState(false)
+ const [couldRouteNav, setCouldRouteNav] = useState(false);
+ const [loading,setLoading] = useState(false);
useEffect(() => {
setCouldRouteNav(false);
@@ -96,13 +97,14 @@ function VideoUploadList (props) {
var userData = '{"Vod":{}}'
if (!uploader) {
+
getUploader(username,
- // Object.assign(uploaderOptions,
{
// 重新创建 才会用最新的 dispatch
create: !uploader,
addFileSuccess: (uploadInfo) => {
- const file = uploadInfo.file
+ setLoading(true);
+ const file = uploadInfo.file;
console.log('addFileSuccess', uploadInfo)
// const newvideos = [...videos, {
// name: file.name,
@@ -121,7 +123,8 @@ function VideoUploadList (props) {
dispatch({type: 'addVideo', uploadInfo})
},
onUploadProgress: (uploadInfo, totalSize, progress) => {
-
+ setLoading(false);
+ console.log("upload",uploadInfo);
var progressPercent = Math.ceil(progress * 100)
// let _index = -1;
@@ -401,19 +404,20 @@ function VideoUploadList (props) {
}}>选择您要上传的视频
{protocolLine}
}
-
-
- {state.videos.map((item, vIndex) => {
- return (
-
- )
- })}
-
+
+
+ {state.videos.map((item, vIndex) => {
+ return (
+
+ )
+ })}
+
+
{state.videos && state.videos.length === MAX_FILE_COUNT &&
{/* */}
From 4d2f30f39e7abf9e6f5ad6b0f1ef8d5778b73fb7 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Mon, 10 Feb 2020 15:57:45 +0800
Subject: [PATCH 7/7] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8E=A5=E5=8F=A3?=
=?UTF-8?q?=E7=9A=84=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/tidings_controller.rb | 6 +++---
db/migrate/20200210071320_migrate_defalut_to_tiding.rb | 7 +++++++
db/migrate/20200210074241_migrate_tiding_status.rb | 9 +++++++++
3 files changed, 19 insertions(+), 3 deletions(-)
create mode 100644 db/migrate/20200210071320_migrate_defalut_to_tiding.rb
create mode 100644 db/migrate/20200210074241_migrate_tiding_status.rb
diff --git a/app/controllers/tidings_controller.rb b/app/controllers/tidings_controller.rb
index 0a28b85e4..9305046b0 100644
--- a/app/controllers/tidings_controller.rb
+++ b/app/controllers/tidings_controller.rb
@@ -19,9 +19,9 @@ class TidingsController < ApplicationController
end
tidings = tidings.where(tiding_type: tiding_types) if tiding_types.present?
- # coures_message_id = current_user.manage_courses.not_deleted.course_messages.join_course_requests.unhandled
- tidings = tidings.where(container_type: 'JoinCourse') if params[:type] == 'course_apply'
- @course_apply_count = tidings.where("created_at > '#{@onclick_time}'").where(container_type: 'JoinCourse').count
+ tidings = tidings.where(container_type: 'JoinCourse', status: 0) if params[:type] == 'course_apply'
+ # @course_apply_count = tidings.where("created_at > '#{@onclick_time}'").where(container_type: 'JoinCourse', status: 0).count
+ @course_apply_count = tidings.where("created_at > '#{@onclick_time}'").where(container_type: 'JoinCourse', status: 0).count
tidings = tidings.where(container_type: 'ProjectPackage') if params[:type] == 'project_package'
diff --git a/db/migrate/20200210071320_migrate_defalut_to_tiding.rb b/db/migrate/20200210071320_migrate_defalut_to_tiding.rb
new file mode 100644
index 000000000..1c0cfc8e9
--- /dev/null
+++ b/db/migrate/20200210071320_migrate_defalut_to_tiding.rb
@@ -0,0 +1,7 @@
+class MigrateDefalutToTiding < ActiveRecord::Migration[5.2]
+ def change
+ change_column_default :tidings, :status, from: nil, to: 0
+
+ Tiding.where(status: nil).update_all(status: 0)
+ end
+end
diff --git a/db/migrate/20200210074241_migrate_tiding_status.rb b/db/migrate/20200210074241_migrate_tiding_status.rb
new file mode 100644
index 000000000..57e5f994d
--- /dev/null
+++ b/db/migrate/20200210074241_migrate_tiding_status.rb
@@ -0,0 +1,9 @@
+class MigrateTidingStatus < ActiveRecord::Migration[5.2]
+ def change
+ Tiding.where(container_type: "JoinCourse", status: 0).each do |tiding|
+ unless CourseMessage.where(course_message_id: tiding.trigger_user_id, course_id: tiding.container_id, course_message_type: "JoinCourseRequest", status: 0).exists?
+ tiding.update!(status: 1)
+ end
+ end
+ end
+end