From 659d0fc88ebbb1b5477057cd9d8ae68461472142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=83=E1=85=AE=E1=84=8B?= =?UTF-8?q?=E1=85=AF=E1=86=AB?= Date: Mon, 30 Oct 2023 13:03:29 +0900 Subject: [PATCH] feat : course video progress to 100 in case fully watched --- .../java/com/m9d/sroom/course/constant/CourseConstant.java | 2 ++ src/main/java/com/m9d/sroom/course/vo/CourseVideo.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/main/java/com/m9d/sroom/course/constant/CourseConstant.java b/src/main/java/com/m9d/sroom/course/constant/CourseConstant.java index cc222435..7d797bd7 100644 --- a/src/main/java/com/m9d/sroom/course/constant/CourseConstant.java +++ b/src/main/java/com/m9d/sroom/course/constant/CourseConstant.java @@ -8,4 +8,6 @@ public class CourseConstant { public static final int PLAYLIST_UPDATE_THRESHOLD_HOURS = 1; public static final int VIDEO_UPDATE_THRESHOLD_HOURS = 1; + + public static final int VIDEO_THRESHOLD_SECONDS_BEFORE_END = 3; } diff --git a/src/main/java/com/m9d/sroom/course/vo/CourseVideo.java b/src/main/java/com/m9d/sroom/course/vo/CourseVideo.java index a2951802..eb47aa3d 100644 --- a/src/main/java/com/m9d/sroom/course/vo/CourseVideo.java +++ b/src/main/java/com/m9d/sroom/course/vo/CourseVideo.java @@ -1,5 +1,6 @@ package com.m9d.sroom.course.vo; +import com.m9d.sroom.course.constant.CourseConstant; import com.m9d.sroom.search.dto.VideoCompletionStatus; import com.m9d.sroom.material.model.MaterialStatus; import lombok.Getter; @@ -27,6 +28,10 @@ public class CourseVideo { private final int maxDuration; public int getProgress(int videoDuration) { + if (videoDuration - CourseConstant.VIDEO_THRESHOLD_SECONDS_BEFORE_END < maxDuration) { + return 100; + } + return (int) (((long) maxDuration * 100) / videoDuration); }