From b14ec9a9282cb49951b790ce1b48b1a078616926 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sun, 15 Oct 2017 19:00:56 -0700 Subject: Refactor Chapter Ordering Logic The bug impacting the CCB integration was due to the "Introduction" chapter having a higher "score" than every other chapter. It was a mistake to use Score to compared chapter progress, particularly since there are more chapters than scores. This change gathers the chapter ordering logic, which was scattered throughout the code into a new Chapters enum. Playlist and Chapter now use Chapters as a key, instead of loose strings. Same for the ProgressReporter interface. --- src/main/java/com/p4square/grow/tools/AttributeBackfillTool.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/main/java/com/p4square/grow/tools/AttributeBackfillTool.java') diff --git a/src/main/java/com/p4square/grow/tools/AttributeBackfillTool.java b/src/main/java/com/p4square/grow/tools/AttributeBackfillTool.java index d7fd2ff..bf9ee7f 100644 --- a/src/main/java/com/p4square/grow/tools/AttributeBackfillTool.java +++ b/src/main/java/com/p4square/grow/tools/AttributeBackfillTool.java @@ -9,6 +9,7 @@ import java.util.Date; import java.util.List; import java.util.Map; +import com.p4square.grow.model.*; import org.restlet.Client; import org.restlet.Context; import org.restlet.data.Protocol; @@ -24,10 +25,6 @@ import com.p4square.grow.backend.dynamo.DynamoKey; import com.p4square.grow.config.Config; -import com.p4square.grow.model.Chapter; -import com.p4square.grow.model.Playlist; -import com.p4square.grow.model.TrainingRecord; -import com.p4square.grow.model.VideoRecord; import com.p4square.grow.provider.JsonEncodedProvider; /** @@ -221,7 +218,7 @@ public class AttributeBackfillTool { Playlist playlist = record.getPlaylist(); chapters: - for (Map.Entry entry : playlist.getChaptersMap().entrySet()) { + for (Map.Entry entry : playlist.getChaptersMap().entrySet()) { Chapter chapter = entry.getValue(); // Find completion date @@ -237,7 +234,7 @@ chapters: } } - String attributeName = "Training Complete - " + entry.getKey(); + String attributeName = "Training Complete - " + entry.getKey().toString().toLowerCase(); // Check if the user already has the attribute. List attributes = f1.getAttribute(userId, attributeName); -- cgit v1.2.3