-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: optimised data loading on dashboard and course details
- Loading branch information
1 parent
46c32a2
commit cd9e651
Showing
22 changed files
with
469 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/build | ||
/google-services.json | ||
/schemas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
core/src/main/java/org/openedx/core/data/model/room/CourseEnrollmentDetailsEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package org.openedx.core.data.model.room | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Embedded | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
import org.openedx.core.data.model.room.discovery.CertificateDb | ||
import org.openedx.core.data.model.room.discovery.CourseAccessDetailsDb | ||
import org.openedx.core.data.model.room.discovery.CourseSharingUtmParametersDb | ||
import org.openedx.core.data.model.room.discovery.EnrollmentDetailsDB | ||
import org.openedx.core.domain.model.CourseEnrollmentDetails | ||
import org.openedx.core.domain.model.CourseInfoOverview | ||
import java.util.Date | ||
|
||
@Entity(tableName = "course_enrollment_details_table") | ||
data class CourseEnrollmentDetailsEntity( | ||
@PrimaryKey | ||
@ColumnInfo("id") | ||
val id: String, | ||
@ColumnInfo("courseUpdates") | ||
val courseUpdates: String, | ||
@ColumnInfo("courseHandouts") | ||
val courseHandouts: String, | ||
@ColumnInfo("discussionUrl") | ||
val discussionUrl: String, | ||
@Embedded | ||
val courseAccessDetails: CourseAccessDetailsDb, | ||
@Embedded | ||
val certificate: CertificateDb?, | ||
@Embedded | ||
val enrollmentDetails: EnrollmentDetailsDB, | ||
@Embedded | ||
val courseInfoOverview: CourseInfoOverviewDb | ||
) { | ||
fun mapToDomain() = CourseEnrollmentDetails( | ||
id = id, | ||
courseUpdates = courseUpdates, | ||
courseHandouts = courseHandouts, | ||
discussionUrl = discussionUrl, | ||
courseAccessDetails = courseAccessDetails.mapToDomain(), | ||
certificate = certificate?.mapToDomain(), | ||
enrollmentDetails = enrollmentDetails.mapToDomain(), | ||
courseInfoOverview = courseInfoOverview.mapToDomain() | ||
) | ||
} | ||
|
||
data class CourseInfoOverviewDb( | ||
@ColumnInfo("name") | ||
val name: String, | ||
@ColumnInfo("number") | ||
val number: String, | ||
@ColumnInfo("org") | ||
val org: String, | ||
@Embedded | ||
val start: Date?, | ||
@ColumnInfo("startDisplay") | ||
val startDisplay: String, | ||
@ColumnInfo("startType") | ||
val startType: String, | ||
@Embedded | ||
val end: Date?, | ||
@ColumnInfo("isSelfPaced") | ||
val isSelfPaced: Boolean, | ||
@Embedded | ||
var media: MediaDb?, | ||
@Embedded | ||
val courseSharingUtmParameters: CourseSharingUtmParametersDb, | ||
@ColumnInfo("courseAbout") | ||
val courseAbout: String, | ||
) { | ||
fun mapToDomain() = CourseInfoOverview( | ||
name = name, | ||
number = number, | ||
org = org, | ||
start = start, | ||
startDisplay = startDisplay, | ||
startType = startType, | ||
end = end, | ||
isSelfPaced = isSelfPaced, | ||
media = media?.mapToDomain(), | ||
courseSharingUtmParameters = courseSharingUtmParameters.mapToDomain(), | ||
courseAbout = courseAbout | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
core/src/main/java/org/openedx/core/extension/CoroutineExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.openedx.core.extension | ||
|
||
import kotlinx.coroutines.channels.ProducerScope | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.channelFlow | ||
import kotlin.experimental.ExperimentalTypeInference | ||
|
||
@OptIn(ExperimentalTypeInference::class) | ||
inline fun <T> channelFlowWithAwait( | ||
@BuilderInference crossinline block: suspend ProducerScope<T>.() -> Unit | ||
) = channelFlow { | ||
block(this) | ||
awaitClose() | ||
} |
Oops, something went wrong.