From 8bbb6767f8cadaeb30f6fd41f7f9a156c4a3d759 Mon Sep 17 00:00:00 2001 From: Eunoia <33084435+Eunoia1729@users.noreply.github.com> Date: Wed, 20 Apr 2022 08:01:47 +0000 Subject: [PATCH 1/2] feat: include storybook-title column during event export --- .../elimu/analytics/entity/StoryBookLearningEvent.java | 9 +++++++++ .../receiver/StoryBookLearningEventReceiver.java | 2 +- .../ai/elimu/analytics/task/ExportEventsToCsvWorker.java | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/ai/elimu/analytics/entity/StoryBookLearningEvent.java b/app/src/main/java/ai/elimu/analytics/entity/StoryBookLearningEvent.java index 6a95c16..2ebc28b 100644 --- a/app/src/main/java/ai/elimu/analytics/entity/StoryBookLearningEvent.java +++ b/app/src/main/java/ai/elimu/analytics/entity/StoryBookLearningEvent.java @@ -10,6 +10,7 @@ public class StoryBookLearningEvent extends LearningEvent { @NonNull private Long storyBookId; + private String storyBookTitle; @NonNull private LearningEventType learningEventType; @@ -22,6 +23,14 @@ public void setStoryBookId(Long storyBookId) { this.storyBookId = storyBookId; } + public String getStoryBookTitle() { + return storyBookTitle; + } + + public void setStoryBookTitle(String storyBookTitle) { + this.storyBookTitle = storyBookTitle; + } + public LearningEventType getLearningEventType() { return learningEventType; } diff --git a/app/src/main/java/ai/elimu/analytics/receiver/StoryBookLearningEventReceiver.java b/app/src/main/java/ai/elimu/analytics/receiver/StoryBookLearningEventReceiver.java index 95be1ad..c03cd56 100644 --- a/app/src/main/java/ai/elimu/analytics/receiver/StoryBookLearningEventReceiver.java +++ b/app/src/main/java/ai/elimu/analytics/receiver/StoryBookLearningEventReceiver.java @@ -44,7 +44,7 @@ public void onReceive(Context context, Intent intent) { storyBookLearningEvent.setPackageName(packageName); storyBookLearningEvent.setTime(timestamp); storyBookLearningEvent.setStoryBookId(storyBookId); -// storyBookLearningEvent.setStoryBookTitle(storyBookTitle); + storyBookLearningEvent.setStoryBookTitle(storyBookTitle); storyBookLearningEvent.setLearningEventType(learningEventType); // Store in database diff --git a/app/src/main/java/ai/elimu/analytics/task/ExportEventsToCsvWorker.java b/app/src/main/java/ai/elimu/analytics/task/ExportEventsToCsvWorker.java index 82531ef..3ee82c5 100644 --- a/app/src/main/java/ai/elimu/analytics/task/ExportEventsToCsvWorker.java +++ b/app/src/main/java/ai/elimu/analytics/task/ExportEventsToCsvWorker.java @@ -334,6 +334,7 @@ private void exportStoryBookLearningEventsToCsv() { "android_id", "package_name", "storybook_id", + "storybook_title", "learning_event_type" ); StringWriter stringWriter = new StringWriter(); @@ -363,6 +364,7 @@ private void exportStoryBookLearningEventsToCsv() { storyBookLearningEvent.getAndroidId(), storyBookLearningEvent.getPackageName(), storyBookLearningEvent.getStoryBookId(), + storyBookLearningEvent.getStoryBookTitle(), storyBookLearningEvent.getLearningEventType() ); csvPrinter.flush(); From cc45f277000286915aa9ddc6752e1a59eac6e9ef Mon Sep 17 00:00:00 2001 From: Eunoia <33084435+Eunoia1729@users.noreply.github.com> Date: Wed, 20 Apr 2022 08:01:47 +0000 Subject: [PATCH 2/2] feat: include storybook-title column during event export --- .../main/java/ai/elimu/analytics/db/RoomDb.java | 16 ++++++++++++++-- .../analytics/entity/StoryBookLearningEvent.java | 10 ++++++++++ .../receiver/StoryBookLearningEventReceiver.java | 2 +- .../analytics/task/ExportEventsToCsvWorker.java | 2 ++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/ai/elimu/analytics/db/RoomDb.java b/app/src/main/java/ai/elimu/analytics/db/RoomDb.java index 9cefbcc..8c4f6dc 100644 --- a/app/src/main/java/ai/elimu/analytics/db/RoomDb.java +++ b/app/src/main/java/ai/elimu/analytics/db/RoomDb.java @@ -25,7 +25,7 @@ import ai.elimu.analytics.entity.WordLearningEvent; import timber.log.Timber; -@Database(version = 5, entities = {LetterLearningEvent.class, LetterAssessmentEvent.class, WordLearningEvent.class, WordAssessmentEvent.class, StoryBookLearningEvent.class}) +@Database(version = 6, entities = {LetterLearningEvent.class, LetterAssessmentEvent.class, WordLearningEvent.class, WordAssessmentEvent.class, StoryBookLearningEvent.class}) @TypeConverters({Converters.class}) public abstract class RoomDb extends RoomDatabase { @@ -54,7 +54,8 @@ public static RoomDb getDatabase(final Context context) { MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, - MIGRATION_4_5 + MIGRATION_4_5, + MIGRATION_5_6 ) .build(); } @@ -107,4 +108,15 @@ public void migrate(@NonNull SupportSQLiteDatabase database) { database.execSQL(sql); } }; + + private static final Migration MIGRATION_5_6 = new Migration(5, 6) { + @Override + public void migrate(@NonNull SupportSQLiteDatabase database) { + Timber.i("migrate (" + database.getVersion() + " --> 6)"); + + String sql = "ALTER TABLE `StoryBookLearningEvent` ADD COLUMN `storyBookTitle` TEXT"; + Timber.i("sql: " + sql); + database.execSQL(sql); + } + }; } diff --git a/app/src/main/java/ai/elimu/analytics/entity/StoryBookLearningEvent.java b/app/src/main/java/ai/elimu/analytics/entity/StoryBookLearningEvent.java index 6a95c16..17eb736 100644 --- a/app/src/main/java/ai/elimu/analytics/entity/StoryBookLearningEvent.java +++ b/app/src/main/java/ai/elimu/analytics/entity/StoryBookLearningEvent.java @@ -11,6 +11,8 @@ public class StoryBookLearningEvent extends LearningEvent { @NonNull private Long storyBookId; + private String storyBookTitle; + @NonNull private LearningEventType learningEventType; @@ -22,6 +24,14 @@ public void setStoryBookId(Long storyBookId) { this.storyBookId = storyBookId; } + public String getStoryBookTitle() { + return storyBookTitle; + } + + public void setStoryBookTitle(String storyBookTitle) { + this.storyBookTitle = storyBookTitle; + } + public LearningEventType getLearningEventType() { return learningEventType; } diff --git a/app/src/main/java/ai/elimu/analytics/receiver/StoryBookLearningEventReceiver.java b/app/src/main/java/ai/elimu/analytics/receiver/StoryBookLearningEventReceiver.java index 95be1ad..c03cd56 100644 --- a/app/src/main/java/ai/elimu/analytics/receiver/StoryBookLearningEventReceiver.java +++ b/app/src/main/java/ai/elimu/analytics/receiver/StoryBookLearningEventReceiver.java @@ -44,7 +44,7 @@ public void onReceive(Context context, Intent intent) { storyBookLearningEvent.setPackageName(packageName); storyBookLearningEvent.setTime(timestamp); storyBookLearningEvent.setStoryBookId(storyBookId); -// storyBookLearningEvent.setStoryBookTitle(storyBookTitle); + storyBookLearningEvent.setStoryBookTitle(storyBookTitle); storyBookLearningEvent.setLearningEventType(learningEventType); // Store in database diff --git a/app/src/main/java/ai/elimu/analytics/task/ExportEventsToCsvWorker.java b/app/src/main/java/ai/elimu/analytics/task/ExportEventsToCsvWorker.java index 82531ef..3ee82c5 100644 --- a/app/src/main/java/ai/elimu/analytics/task/ExportEventsToCsvWorker.java +++ b/app/src/main/java/ai/elimu/analytics/task/ExportEventsToCsvWorker.java @@ -334,6 +334,7 @@ private void exportStoryBookLearningEventsToCsv() { "android_id", "package_name", "storybook_id", + "storybook_title", "learning_event_type" ); StringWriter stringWriter = new StringWriter(); @@ -363,6 +364,7 @@ private void exportStoryBookLearningEventsToCsv() { storyBookLearningEvent.getAndroidId(), storyBookLearningEvent.getPackageName(), storyBookLearningEvent.getStoryBookId(), + storyBookLearningEvent.getStoryBookTitle(), storyBookLearningEvent.getLearningEventType() ); csvPrinter.flush();