From b2daa540b7cf730b8c16432a82be4ab9452fd5f8 Mon Sep 17 00:00:00 2001 From: Anuraag Mishra Date: Thu, 23 Mar 2017 23:01:23 +0530 Subject: [PATCH 1/5] aDR=DRESSES ISSUE #6 BY CHANGING THE NO. OF EXAMPLES TO 3 --- .../com/teamtreehouse/flashy/controllers/IndexController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java b/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java index f127754..6ebbcac 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()); From 45d2dda2af39df8ab173bc728777ac931cc9ada4 Mon Sep 17 00:00:00 2001 From: Anuraag Mishra Date: Thu, 23 Mar 2017 23:16:36 +0530 Subject: [PATCH 2/5] Addresses bug described in #6 where the total count in the call to action was off --- .../flashy/controllers/IndexController.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java b/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java index 6ebbcac..61af339 100644 --- a/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java +++ b/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java @@ -31,10 +31,13 @@ public String index(Model model) { ctaBuilder.append(", "); } } - ctaBuilder.append(" and "); Long totalCount = flashCardService.getCurrentCount(); - ctaBuilder.append(totalCount); - 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 e4b6e955fb1cf8ee1687d830e1d372797c637f40 Mon Sep 17 00:00:00 2001 From: Anuraag Mishra Date: Thu, 23 Mar 2017 23:27:39 +0530 Subject: [PATCH 3/5] Doing commit again to test push effect from intellij to github --- .idea/codeStyleSettings.xml | 9 +++++++++ .idea/misc.xml | 15 +-------------- .../flashy/controllers/IndexController.java | 2 +- 3 files changed, 11 insertions(+), 15 deletions(-) create mode 100644 .idea/codeStyleSettings.xml diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml new file mode 100644 index 0000000..5dfbdec --- /dev/null +++ b/.idea/codeStyleSettings.xml @@ -0,0 +1,9 @@ + + + + + + \ No newline at end of file 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/controllers/IndexController.java b/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java index 61af339..f88c7b2 100644 --- a/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java +++ b/src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java @@ -32,7 +32,7 @@ public String index(Model model) { } } Long totalCount = flashCardService.getCurrentCount(); - if (totalCount > AMOUNT_TO_SHOW){ + if (totalCount > AMOUNT_TO_SHOW ){ ctaBuilder.append(" and "); ctaBuilder.append(totalCount - AMOUNT_TO_SHOW); ctaBuilder.append(" more"); From b3d5403cce9b1c99ca9f1ad00d96eafb65d9919c Mon Sep 17 00:00:00 2001 From: Anuraag Mishra Date: Fri, 24 Mar 2017 22:40:59 +0530 Subject: [PATCH 4/5] Fixes #5 by displaying cards more standard --- .../teamtreehouse/flashy/services/FlashCardServiceImpl.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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); } From 2684f33ea24cd1bf386c7c3e9539059fa2a667f3 Mon Sep 17 00:00:00 2001 From: Anuraag Mishra Date: Fri, 24 Mar 2017 22:42:39 +0530 Subject: [PATCH 5/5] Fixes #5 by displaying cards more standard --- .idea/modules/java-debugging-flashy.iml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .idea/modules/java-debugging-flashy.iml diff --git a/.idea/modules/java-debugging-flashy.iml b/.idea/modules/java-debugging-flashy.iml new file mode 100644 index 0000000..6dd3f64 --- /dev/null +++ b/.idea/modules/java-debugging-flashy.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file