Skip to content

Commit

Permalink
feat : course video progress to 100 in case fully watched
Browse files Browse the repository at this point in the history
  • Loading branch information
D-w-nJ committed Oct 30, 2023
1 parent e96d371 commit 659d0fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
5 changes: 5 additions & 0 deletions src/main/java/com/m9d/sroom/course/vo/CourseVideo.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 659d0fc

Please sign in to comment.