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

feat: Added offline support for CourseEnrollmentDetails API #69

Merged
merged 3 commits into from
Dec 6, 2024

Conversation

omerhabib26
Copy link

Description:

  • Store CourseEnrollmentDetails API response in DB for offline mode
  • Return DB response if device is offline

fix: LEARNER-10282

@omerhabib26 omerhabib26 force-pushed the 2U/omer/LEARNER-10282 branch from a59532a to a01f356 Compare November 29, 2024 13:41
@@ -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) {
Copy link
Member

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")
Copy link
Member

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.

Comment on lines 63 to 79
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
)
"""
)
}
}
Copy link
Member

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.

Comment on lines 269 to 270
@Embedded
val coursewareAccess: CoursewareAccessDb?,
Copy link
Member

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.

Comment on lines 6 to 8
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
import org.openedx.core.data.model.room.CourseEnrollmentDetailsEntity
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs auto-format.

Copy link
Member

@farhan-arshad-dev farhan-arshad-dev left a 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()

Copy link
Member

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>()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

courseEnrollmentDetails can local.

@omerhabib26 omerhabib26 merged commit 9a199f6 into 2U/develop Dec 6, 2024
3 checks passed
@omerhabib26 omerhabib26 deleted the 2U/omer/LEARNER-10282 branch December 6, 2024 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants