From 97af74222e42d310a8030a61939990ad0eae436d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 16 Mar 2020 17:50:54 +0800 Subject: [PATCH] =?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/jobs/student_join_attendance_record_job.rb | 2 +- app/models/course_member.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/jobs/student_join_attendance_record_job.rb b/app/jobs/student_join_attendance_record_job.rb index ecc0b46a9..8840ae142 100644 --- a/app/jobs/student_join_attendance_record_job.rb +++ b/app/jobs/student_join_attendance_record_job.rb @@ -4,7 +4,7 @@ class StudentJoinAttendanceRecordJob < ApplicationJob def perform(member_id) member = CourseMember.find_by(id: member_id) course = member&.course - return if member.blank? || course.blank? + return if member.blank? || member.role != "STUDENT" || course.blank? current_date = Date.current current_end_time = Time.current.strftime("%H:%M:%S") diff --git a/app/models/course_member.rb b/app/models/course_member.rb index 21221e7e9..0a0433f6f 100644 --- a/app/models/course_member.rb +++ b/app/models/course_member.rb @@ -165,7 +165,9 @@ class CourseMember < ApplicationRecord private def create_attendance_record - StudentJoinAttendanceRecordJob.perform_later(id) + if role == "STUDENT" + StudentJoinAttendanceRecordJob.perform_later(id) + end end end