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

[un-tested] feat: include storybook-title column during event export #123

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 14 additions & 2 deletions app/src/main/java/ai/elimu/analytics/db/RoomDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class StoryBookLearningEvent extends LearningEvent {
@NonNull
private Long storyBookId;

private String storyBookTitle;
nya-elimu marked this conversation as resolved.
Show resolved Hide resolved

@NonNull
private LearningEventType learningEventType;

Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ private void exportStoryBookLearningEventsToCsv() {
"android_id",
"package_name",
"storybook_id",
"storybook_title",
"learning_event_type"
);
StringWriter stringWriter = new StringWriter();
Expand Down Expand Up @@ -363,6 +364,7 @@ private void exportStoryBookLearningEventsToCsv() {
storyBookLearningEvent.getAndroidId(),
storyBookLearningEvent.getPackageName(),
storyBookLearningEvent.getStoryBookId(),
storyBookLearningEvent.getStoryBookTitle(),
storyBookLearningEvent.getLearningEventType()
);
csvPrinter.flush();
Expand Down