Skip to content

Commit

Permalink
fix: [ANDROAPP-6185] dashboard event list not updated
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmateos committed May 28, 2024
1 parent 8c1e94b commit 2dec32e
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.dhis2.usescases.teiDashboard
import org.dhis2.ui.MetadataIconData
import org.hisp.dhis.android.core.enrollment.Enrollment
import org.hisp.dhis.android.core.enrollment.EnrollmentStatus
import org.hisp.dhis.android.core.event.Event
import org.hisp.dhis.android.core.organisationunit.OrganisationUnit
import org.hisp.dhis.android.core.program.Program
import org.hisp.dhis.android.core.program.ProgramStage
Expand Down Expand Up @@ -31,7 +30,6 @@ sealed class DashboardModel(
data class DashboardEnrollmentModel(
val currentEnrollment: Enrollment,
val programStages: List<ProgramStage>,
val eventModels: List<Event>,
override val trackedEntityInstance: TrackedEntityInstance,
val trackedEntityAttributes: List<Pair<TrackedEntityAttribute, TrackedEntityAttributeValue>>,
override val trackedEntityAttributeValues: List<TrackedEntityAttributeValue>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ interface DashboardRepository {

fun getEnrollment(): Observable<Enrollment>

fun getTEIEnrollmentEvents(programUid: String?, teiUid: String): Observable<List<Event>>

fun getEnrollmentEventsWithDisplay(
programUid: String?,
teiUid: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.dhis2.commons.prefs.Preference
import org.dhis2.commons.prefs.PreferenceProvider
import org.dhis2.commons.resources.MetadataIconProvider
import org.dhis2.ui.MetadataIconData
import org.dhis2.utils.DateUtils
import org.dhis2.utils.ValueUtils
import org.hisp.dhis.android.core.D2
import org.hisp.dhis.android.core.arch.helpers.UidsHelper.getUidsList
Expand Down Expand Up @@ -68,30 +67,6 @@ class DashboardRepositoryImpl(
.toObservable()
}

override fun getTEIEnrollmentEvents(
programUid: String?,
teiUid: String,
): Observable<List<Event>> {
return d2.eventModule().events().byEnrollmentUid().eq(enrollmentUid)
.byDeleted().isFalse
.orderByTimeline(RepositoryScope.OrderByDirection.ASC)
.get().toFlowable().flatMapIterable { events: List<Event>? -> events }.distinct()
.map { event: Event ->
var event = event
if (java.lang.Boolean.FALSE
== d2.programModule().programs().uid(programUid).blockingGet()!!
.ignoreOverdueEvents()
) if (event.status() == EventStatus.SCHEDULE &&
event.dueDate()!!
.before(DateUtils.getInstance().today)
) {
event = updateState(event, EventStatus.OVERDUE)
}
event
}.toList()
.toObservable()
}

override fun getEnrollmentEventsWithDisplay(
programUid: String?,
teiUid: String,
Expand Down Expand Up @@ -388,7 +363,6 @@ class DashboardRepositoryImpl(
DashboardEnrollmentModel(
getEnrollment().blockingFirst(),
getProgramStages(programUid).blockingFirst(),
getTEIEnrollmentEvents(programUid, teiUid).blockingFirst(),
getTrackedEntityInstance(teiUid).blockingFirst(),
getAttributesMap(programUid, teiUid).blockingFirst(),
getTEIAttributeValues(programUid, teiUid).blockingFirst(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import io.reactivex.Completable
import io.reactivex.Flowable
import io.reactivex.Observable
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.processors.BehaviorProcessor
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -197,32 +196,6 @@ class TEIDataPresenter(
dashboardRepository.saveCatOption(eventUid, catOptionComboUid)
}

fun areEventsCompleted() {
compositeDisposable.add(
dashboardRepository.getEnrollmentEventsWithDisplay(programUid, teiUid)
.flatMap { events ->
if (events.isEmpty()) {
dashboardRepository.getTEIEnrollmentEvents(
programUid,
teiUid,
)
} else {
Observable.just(events)
}
}
.map { events ->
Observable.fromIterable(events)
.all { event -> event.status() == EventStatus.COMPLETED }
}
.subscribeOn(schedulerProvider.io())
.observeOn(schedulerProvider.ui())
.subscribe(
view.areEventsCompleted(),
Timber.Forest::d,
),
)
}

fun displayGenerateEvent(eventUid: String?) {
compositeDisposable.add(
dashboardRepository.displayGenerateEvent(eventUid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.dhis2.utils.analytics.CLICK
import org.dhis2.utils.analytics.DELETE_TEI
import org.hisp.dhis.android.core.enrollment.Enrollment
import org.hisp.dhis.android.core.enrollment.EnrollmentStatus
import org.hisp.dhis.android.core.event.Event
import org.hisp.dhis.android.core.organisationunit.OrganisationUnit
import org.hisp.dhis.android.core.program.Program
import org.hisp.dhis.android.core.program.ProgramStage
Expand Down Expand Up @@ -70,7 +69,6 @@ class TeiDashboardPresenterTest {
val trackedEntityInstance = TrackedEntityInstance.builder().uid(teiUid).build()
val enrollment = Enrollment.builder().uid("enrollmentUid").build()
val programStages = listOf(ProgramStage.builder().uid("programStageUid").build())
val events = listOf(Event.builder().uid("eventUid").build())
val trackedEntityAttributes = listOf(
Pair(
TrackedEntityAttribute.builder().uid("teiAttr").build(),
Expand All @@ -95,9 +93,6 @@ class TeiDashboardPresenterTest {
whenever(
repository.getProgramStages(programUid),
) doReturn Observable.just(programStages)
whenever(
repository.getTEIEnrollmentEvents(programUid, teiUid),
) doReturn Observable.just(events)
whenever(
repository.getAttributesMap(programUid, teiUid),
) doReturn Observable.just(trackedEntityAttributes)
Expand Down

0 comments on commit 2dec32e

Please sign in to comment.