Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(csv): handle nullpointer when no storybook_id in database #1865

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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