Skip to content

Commit

Permalink
fix(csv): handle nullpointer when no storybook_id in database (#1865)
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-elimu authored Aug 25, 2024
2 parents 7166a4a + 8a161aa commit 11edd31
Showing 1 changed file with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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,
Expand All @@ -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",
Expand All @@ -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()
);
Expand Down

0 comments on commit 11edd31

Please sign in to comment.