From b1ca9c90a36665b31fdf13725e9ec4a80e99d0ac Mon Sep 17 00:00:00 2001 From: Joe Samyn <19joe.samyn96@gmail.com> Date: Wed, 10 Oct 2018 21:49:46 -0400 Subject: [PATCH 1/3] Addresses issue number 6 by changing the number of examples to 3. --- .../teamtreehouse/flashy/controllers/IndexController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java b/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java index f127754..7ba22d0 100644 --- a/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java +++ b/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java @@ -12,6 +12,7 @@ @Controller public class IndexController { + public static final int AMOUNT_TO_SHOW = 3; private FlashCardService flashCardService; @Autowired @@ -22,7 +23,7 @@ public void setFlashCardService(FlashCardService flashCardService) { @RequestMapping("/") public String index(Model model) { StringBuilder ctaBuilder = new StringBuilder(); - List cards = flashCardService.getRandomFlashCards(5); + List cards = flashCardService.getRandomFlashCards(AMOUNT_TO_SHOW); ctaBuilder.append("Refresh your memory about "); for (FlashCard card : cards) { ctaBuilder.append(card.getTerm()); @@ -32,7 +33,7 @@ public String index(Model model) { } ctaBuilder.append(" and "); Long totalCount = flashCardService.getCurrentCount(); - ctaBuilder.append(totalCount); + ctaBuilder.append(totalCount-AMOUNT_TO_SHOW); ctaBuilder.append(" more"); model.addAttribute("cta", ctaBuilder.toString()); model.addAttribute("flashCardCount", totalCount); From ce2a2e29b98fc02c9687765e872f13300f27e259 Mon Sep 17 00:00:00 2001 From: Joe Samyn <19joe.samyn96@gmail.com> Date: Sun, 14 Oct 2018 16:50:13 -0700 Subject: [PATCH 2/3] Addresses issue number 6 by changing the number of examples to 3. --- .idea/modules/flashy.iml | 1 + .idea/modules/flashy_main.iml | 14 ++++++++++++-- .idea/modules/flashy_test.iml | 15 +++++++++++++-- .../flashy/controllers/IndexController.java | 8 +++++--- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.idea/modules/flashy.iml b/.idea/modules/flashy.iml index 2f6b1cf..91b9bed 100644 --- a/.idea/modules/flashy.iml +++ b/.idea/modules/flashy.iml @@ -5,6 +5,7 @@ + diff --git a/.idea/modules/flashy_main.iml b/.idea/modules/flashy_main.iml index 3d7e5d1..8618301 100644 --- a/.idea/modules/flashy_main.iml +++ b/.idea/modules/flashy_main.iml @@ -1,7 +1,17 @@ - - + + + + + + + + + + + + diff --git a/.idea/modules/flashy_test.iml b/.idea/modules/flashy_test.iml index 3c5b73a..603f95e 100644 --- a/.idea/modules/flashy_test.iml +++ b/.idea/modules/flashy_test.iml @@ -1,7 +1,18 @@ - - + + + + + + + + + + + + + diff --git a/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java b/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java index 7ba22d0..57f1664 100644 --- a/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java +++ b/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java @@ -31,10 +31,12 @@ public String index(Model model) { ctaBuilder.append(", "); } } - ctaBuilder.append(" and "); Long totalCount = flashCardService.getCurrentCount(); - ctaBuilder.append(totalCount-AMOUNT_TO_SHOW); - ctaBuilder.append(" more"); + if(totalCount > AMOUNT_TO_SHOW){ + ctaBuilder.append(" and "); + ctaBuilder.append(totalCount-AMOUNT_TO_SHOW); + ctaBuilder.append(" more"); + } model.addAttribute("cta", ctaBuilder.toString()); model.addAttribute("flashCardCount", totalCount); return "index"; From 6f8f301a5e1c4fd35f753e7d2134e5767390641e Mon Sep 17 00:00:00 2001 From: Joe Samyn <19joe.samyn96@gmail.com> Date: Sun, 14 Oct 2018 17:54:29 -0700 Subject: [PATCH 3/3] Fixes issue #5 by making the cards displayed more standard. --- .idea/misc.xml | 15 +-------------- .../flashy/services/FlashCardServiceImpl.java | 5 ++--- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 164b970..d5d79e0 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,19 +1,6 @@ - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/main/java/com/teamtreehouse/flashy/services/FlashCardServiceImpl.java b/src/main/java/com/teamtreehouse/flashy/services/FlashCardServiceImpl.java index 5b660e9..bb24770 100644 --- a/src/main/java/com/teamtreehouse/flashy/services/FlashCardServiceImpl.java +++ b/src/main/java/com/teamtreehouse/flashy/services/FlashCardServiceImpl.java @@ -62,10 +62,9 @@ public FlashCard getNextFlashCardBasedOnViews(Map idToViewCounts) { continue; } Long lowestScore = idToViewCounts.get(leastViewedId); - if (entry.getValue() >= lowestScore) { - break; + if (entry.getValue() < lowestScore) { + leastViewedId = entry.getKey(); } - leastViewedId = entry.getKey(); } return flashCardRepository.findOne(leastViewedId); }