From ca01e1744569173fe54d5c221f14d39791c32030 Mon Sep 17 00:00:00 2001 From: jo-elimu <1451036+jo-elimu@users.noreply.github.com> Date: Sat, 24 Aug 2024 16:47:19 +0700 Subject: [PATCH 1/4] refactor: restore nav --- .../webapp/WEB-INF/jsp/analytics/layout.jsp | 170 ++++++++++-------- 1 file changed, 98 insertions(+), 72 deletions(-) diff --git a/src/main/webapp/WEB-INF/jsp/analytics/layout.jsp b/src/main/webapp/WEB-INF/jsp/analytics/layout.jsp index 5a4e18cea..7b0ee8d19 100644 --- a/src/main/webapp/WEB-INF/jsp/analytics/layout.jsp +++ b/src/main/webapp/WEB-INF/jsp/analytics/layout.jsp @@ -45,21 +45,32 @@ From 5c791a628a87beaa11ea3c9bb85edef43ec216bf Mon Sep 17 00:00:00 2001 From: jo-elimu <1451036+jo-elimu@users.noreply.github.com> Date: Sat, 24 Aug 2024 16:49:14 +0700 Subject: [PATCH 2/4] refactor: remove contributor dropdown #411 --- .../webapp/WEB-INF/jsp/analytics/layout.jsp | 110 +----------------- 1 file changed, 1 insertion(+), 109 deletions(-) diff --git a/src/main/webapp/WEB-INF/jsp/analytics/layout.jsp b/src/main/webapp/WEB-INF/jsp/analytics/layout.jsp index 7b0ee8d19..0834dfa5f 100644 --- a/src/main/webapp/WEB-INF/jsp/analytics/layout.jsp +++ b/src/main/webapp/WEB-INF/jsp/analytics/layout.jsp @@ -62,120 +62,12 @@ dehaze -
+
-
- - - -
From 5d65c737d87b2d9bd00e4943636f7f4e09d2068a Mon Sep 17 00:00:00 2001 From: jo-elimu <1451036+jo-elimu@users.noreply.github.com> Date: Sat, 24 Aug 2024 21:47:51 +0700 Subject: [PATCH 3/4] feat: visualize storybook learning events #411 --- .../StoryBookLearningEventListController.java | 34 +++++++++++++++++++ .../storybook-learning-event/list.jsp | 11 ++---- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/main/java/ai/elimu/web/analytics/StoryBookLearningEventListController.java b/src/main/java/ai/elimu/web/analytics/StoryBookLearningEventListController.java index 95f9dfc5d..b652451e5 100644 --- a/src/main/java/ai/elimu/web/analytics/StoryBookLearningEventListController.java +++ b/src/main/java/ai/elimu/web/analytics/StoryBookLearningEventListController.java @@ -2,6 +2,10 @@ import ai.elimu.dao.StoryBookLearningEventDao; import ai.elimu.model.analytics.StoryBookLearningEvent; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; import java.util.List; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -26,6 +30,36 @@ public String handleRequest(Model model) { List storyBookLearningEvents = storyBookLearningEventDao.readAllOrderedByTime(); model.addAttribute("storyBookLearningEvents", storyBookLearningEvents); + + // Prepare data for chart in UI + List monthList = new ArrayList<>(); + List eventCountList = new ArrayList<>(); + if (!storyBookLearningEvents.isEmpty()) { + Calendar calendar4YearsAgo = Calendar.getInstance(); + calendar4YearsAgo.add(Calendar.YEAR, -4); + + Calendar calendarNow = Calendar.getInstance(); + + Calendar month = calendar4YearsAgo; + while (!month.after(calendarNow)) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM-yyyy"); + String monthAsString = simpleDateFormat.format(month.getTime()); + monthList.add(monthAsString); + + int eventCount = 0; + for (StoryBookLearningEvent storyBookLearningEvent : storyBookLearningEvents) { + String eventMonthAsString = simpleDateFormat.format(storyBookLearningEvent.getTimestamp().getTime()); + if (eventMonthAsString.equals(monthAsString)) { + eventCount++; + } + } + eventCountList.add(eventCount); + + month.add(Calendar.MONTH, 1); + } + } + model.addAttribute("monthList", monthList); + model.addAttribute("eventCountList", eventCountList); return "analytics/storybook-learning-event/list"; } diff --git a/src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp b/src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp index 295c83d1a..65555d661 100644 --- a/src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp +++ b/src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp @@ -10,20 +10,15 @@