-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: Added offline support for CourseEnrollmentDetails API #69
Conversation
- Store API response in DB for offline mode fix: LEARNER-10282
a59532a
to
a01f356
Compare
@@ -12,4 +12,69 @@ object Migrations { | |||
db.execSQL("ALTER TABLE download_model ADD COLUMN transcriptDownloadedStatus TEXT NOT NULL DEFAULT 'NOT_DOWNLOADED'") | |||
} | |||
} | |||
|
|||
val MIGRATION_2_3 = object : Migration(2, 3) { | |||
override fun migrate(database: SupportSQLiteDatabase) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use db
instead of database
to make the naming convention consistent.
val MIGRATION_2_3 = object : Migration(2, 3) { | ||
override fun migrate(database: SupportSQLiteDatabase) { | ||
|
||
database.execSQL("DROP TABLE IF EXISTS course_enrollment_details_table") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specific use-case to delete the old table?
cuz this will delete the data along with the table structure. also already using CREATE TABLE IF NOT EXISTS
in the next statement.
database.execSQL( | ||
""" | ||
CREATE TABLE IF NOT EXISTS course_modes_table ( | ||
course_id TEXT NOT NULL, | ||
slug TEXT, | ||
sku TEXT, | ||
androidSku TEXT, | ||
iosSku TEXT, | ||
minPrice REAL, | ||
storeSku TEXT, | ||
PRIMARY KEY(course_id, slug), | ||
FOREIGN KEY(course_id) REFERENCES course_enrollment_details_table(id) ON DELETE CASCADE | ||
) | ||
""" | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it can be removed, as the course_modes_table is not being used elsewhere.
also using CourseModeDB
as Column.
@Embedded | ||
val coursewareAccess: CoursewareAccessDb?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code change in this file can be reverted.
import androidx.room.migration.Migration | ||
import androidx.sqlite.db.SupportSQLiteDatabase | ||
import org.openedx.core.data.model.room.CourseEnrollmentDetailsEntity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs auto-format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some nits, other than that LGTM 🚀 .
val response = api.getEnrollmentDetails(courseId = courseId) | ||
courseDao.insertCourseEnrollmentDetails(response.mapToRoomEntity()) | ||
courseEnrollmentDetails[courseId] = response.mapToDomain() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra line can be removed.
@@ -21,6 +21,7 @@ class CourseRepository( | |||
private val networkConnection: NetworkConnection, | |||
) { | |||
private var courseStructure = mutableMapOf<String, CourseStructure>() | |||
private var courseEnrollmentDetails = mutableMapOf<String, CourseEnrollmentDetails>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
courseEnrollmentDetails
can local.
Description:
fix: LEARNER-10282