|
|
@ -23,7 +23,7 @@ class CreateWatchVideoService < ApplicationService
|
|
|
|
watch_video_history.end_at = current_time
|
|
|
|
watch_video_history.end_at = current_time
|
|
|
|
watch_video_history.total_duration = params[:total_duration]
|
|
|
|
watch_video_history.total_duration = params[:total_duration]
|
|
|
|
watch_video_history.watch_duration = params[:watch_duration].to_f > watch_video_history.duration ? watch_video_history.duration : params[:watch_duration]
|
|
|
|
watch_video_history.watch_duration = params[:watch_duration].to_f > watch_video_history.duration ? watch_video_history.duration : params[:watch_duration]
|
|
|
|
watch_video_history.is_finished = (watch_video_history.duration <= params[:watch_duration].to_f)
|
|
|
|
watch_video_history.is_finished = params[:ed].present?
|
|
|
|
watch_video_history.save!
|
|
|
|
watch_video_history.save!
|
|
|
|
|
|
|
|
|
|
|
|
watch_course_video = watch_video_history.watch_course_video
|
|
|
|
watch_course_video = watch_video_history.watch_course_video
|
|
|
@ -31,7 +31,9 @@ class CreateWatchVideoService < ApplicationService
|
|
|
|
if watch_course_video.present? && !watch_course_video.is_finished && watch_course_video.watch_duration < params[:watch_duration].to_f
|
|
|
|
if watch_course_video.present? && !watch_course_video.is_finished && watch_course_video.watch_duration < params[:watch_duration].to_f
|
|
|
|
# 更新课程视频的时长及是否看完状态
|
|
|
|
# 更新课程视频的时长及是否看完状态
|
|
|
|
watch_course_video.watch_duration = params[:watch_duration]
|
|
|
|
watch_course_video.watch_duration = params[:watch_duration]
|
|
|
|
watch_course_video.is_finished = (watch_course_video.duration <= params[:watch_duration].to_f)
|
|
|
|
if params[:ed].present?
|
|
|
|
|
|
|
|
watch_course_video.is_finished = watch_course_video.watch_video_histories.sum(:total_duration) >= watch_course_video.duration
|
|
|
|
|
|
|
|
end
|
|
|
|
watch_course_video.end_at = current_time
|
|
|
|
watch_course_video.end_at = current_time
|
|
|
|
watch_course_video.save!
|
|
|
|
watch_course_video.save!
|
|
|
|
end
|
|
|
|
end
|
|
|
|