Skip to content

Commit ea869d4

Browse files
committed
Addresed bug described in #6
1 parent 4334710 commit ea869d4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/com/teamtreehouse/flashy/controllers/IndexController.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@Controller
1414
public class IndexController {
15-
public static final int AMOUNT_TO_SHOW = 5;
15+
public static final int AMOUNT_TO_SHOW = 3;
1616
private FlashCardService flashCardService;
1717

1818
@Autowired
@@ -31,10 +31,12 @@ public String index(Model model) {
3131
ctaBuilder.append(", ");
3232
}
3333
}
34-
ctaBuilder.append(" and ");
3534
Long totalCount = flashCardService.getCurrentCount();
36-
ctaBuilder.append(totalCount);
37-
ctaBuilder.append(" more");
35+
if (totalCount > AMOUNT_TO_SHOW) {
36+
ctaBuilder.append(" and ");
37+
ctaBuilder.append(totalCount - AMOUNT_TO_SHOW);
38+
ctaBuilder.append(" more");
39+
}
3840
model.addAttribute("cta", ctaBuilder.toString());
3941
model.addAttribute("flashCardCount", totalCount);
4042
return "index";

0 commit comments

Comments
 (0)