From 8a161aa119f5bfabe55ef4ec3c9bc58196c10ec6 Mon Sep 17 00:00:00 2001 From: jo-elimu <1451036+jo-elimu@users.noreply.github.com> Date: Sun, 25 Aug 2024 20:19:27 +0700 Subject: [PATCH] fix(csv): handle nullpointer when no storybook_id in database refs #1862 --- .../StoryBookLearningEventCsvExportController.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/java/ai/elimu/web/analytics/StoryBookLearningEventCsvExportController.java b/src/main/java/ai/elimu/web/analytics/StoryBookLearningEventCsvExportController.java index 4b6ca72eb..9ed2cea85 100644 --- a/src/main/java/ai/elimu/web/analytics/StoryBookLearningEventCsvExportController.java +++ b/src/main/java/ai/elimu/web/analytics/StoryBookLearningEventCsvExportController.java @@ -1,8 +1,6 @@ package ai.elimu.web.analytics; -import ai.elimu.dao.StoryBookChapterDao; import ai.elimu.dao.StoryBookLearningEventDao; -import ai.elimu.dao.StoryBookParagraphDao; import ai.elimu.model.analytics.StoryBookLearningEvent; import java.io.IOException; import java.io.OutputStream; @@ -29,12 +27,6 @@ public class StoryBookLearningEventCsvExportController { @Autowired private StoryBookLearningEventDao storyBookLearningEventDao; - @Autowired - private StoryBookChapterDao storyBookChapterDao; - - @Autowired - private StoryBookParagraphDao storyBookParagraphDao; - @RequestMapping(value="/storybook-learning-events.csv", method = RequestMethod.GET) public void handleRequest( HttpServletResponse response, @@ -48,7 +40,7 @@ public void handleRequest( CSVFormat csvFormat = CSVFormat.DEFAULT .withHeader( "id", // The Room database ID - "time", + "timestamp", "android_id", "package_name", "storybook_id", @@ -67,7 +59,7 @@ public void handleRequest( storyBookLearningEvent.getTimestamp().getTimeInMillis(), storyBookLearningEvent.getAndroidId(), storyBookLearningEvent.getPackageName(), - storyBookLearningEvent.getStoryBook().getId(), + (storyBookLearningEvent.getStoryBook() == null) ? null : storyBookLearningEvent.getStoryBook().getId(), storyBookLearningEvent.getStoryBookTitle(), storyBookLearningEvent.getLearningEventType() );