summaryrefslogtreecommitdiff
path: root/src/main/java/com/p4square/grow/model
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2017-10-08 17:29:48 -0700
committerJesse Morgan <jesse@jesterpm.net>2017-10-08 17:29:48 -0700
commit79b8aacbb7b347bba9d14b1332666e7263a3a058 (patch)
treec2b38b63a636984c055b1e67eea8d56dd42a77a2 /src/main/java/com/p4square/grow/model
parentcbf149af1f07bb98c1f856948a79dcf3fb0c43b3 (diff)
Attempt to update chapter completion on every request.20171008
I'm still seeing occasional users with missing progress information in CCB. Currently, the progress is only updated when the user completes a chapter. With this change, the progress will be updated every time the training page is loaded. CCBProgressReporter does not actually update the user's profile unless the new level is greater than the existing level. This provision will prevent needlessly calling the CCB API. Additionally, this update will execute in a background thread to avoid impacting the page load.
Diffstat (limited to 'src/main/java/com/p4square/grow/model')
-rw-r--r--src/main/java/com/p4square/grow/model/Chapter.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/com/p4square/grow/model/Chapter.java b/src/main/java/com/p4square/grow/model/Chapter.java
index 3a08e4c..ac27de6 100644
--- a/src/main/java/com/p4square/grow/model/Chapter.java
+++ b/src/main/java/com/p4square/grow/model/Chapter.java
@@ -4,6 +4,7 @@
package com.p4square.grow.model;
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -98,6 +99,26 @@ public class Chapter implements Cloneable {
}
/**
+ * @return the completion date for the chapter, or null if it has not been completed.
+ */
+ @JsonIgnore
+ public Date getCompletionDate() {
+ Date latest = new Date(0);
+ for (VideoRecord video : mVideos.values()) {
+ if (video.getRequired() && !video.getComplete()) {
+ // Hey, this chapter isn't complete!
+ return null;
+ }
+
+ Date completionDate = video.getCompletionDate();
+ if (completionDate.after(latest)) {
+ latest = completionDate;
+ }
+ }
+ return latest;
+ }
+
+ /**
* Deeply clone a chapter.
*
* @return a new Chapter object identical but independent of this one.