From 2dec32ee5edd3ddc6fd36e77c67dda3a4afa73c2 Mon Sep 17 00:00:00 2001 From: manu Date: Tue, 28 May 2024 10:26:40 +0200 Subject: [PATCH] fix: [ANDROAPP-6185] dashboard event list not updated --- .../teiDashboard/DashboardProgramModel.kt | 2 -- .../teiDashboard/DashboardRepository.kt | 2 -- .../teiDashboard/DashboardRepositoryImpl.kt | 26 ------------------ .../teidata/TEIDataPresenter.kt | 27 ------------------- .../teiDashboard/TeiDashboardPresenterTest.kt | 5 ---- 5 files changed, 62 deletions(-) diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardProgramModel.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardProgramModel.kt index cb2e20440a..57393ff42b 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardProgramModel.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardProgramModel.kt @@ -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 @@ -31,7 +30,6 @@ sealed class DashboardModel( data class DashboardEnrollmentModel( val currentEnrollment: Enrollment, val programStages: List, - val eventModels: List, override val trackedEntityInstance: TrackedEntityInstance, val trackedEntityAttributes: List>, override val trackedEntityAttributeValues: List, diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardRepository.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardRepository.kt index f8905414a4..e6d6353c20 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardRepository.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardRepository.kt @@ -29,8 +29,6 @@ interface DashboardRepository { fun getEnrollment(): Observable - fun getTEIEnrollmentEvents(programUid: String?, teiUid: String): Observable> - fun getEnrollmentEventsWithDisplay( programUid: String?, teiUid: String, diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardRepositoryImpl.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardRepositoryImpl.kt index 9700c6d1c8..a123aa9781 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardRepositoryImpl.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/DashboardRepositoryImpl.kt @@ -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 @@ -68,30 +67,6 @@ class DashboardRepositoryImpl( .toObservable() } - override fun getTEIEnrollmentEvents( - programUid: String?, - teiUid: String, - ): Observable> { - return d2.eventModule().events().byEnrollmentUid().eq(enrollmentUid) - .byDeleted().isFalse - .orderByTimeline(RepositoryScope.OrderByDirection.ASC) - .get().toFlowable().flatMapIterable { events: List? -> 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, @@ -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(), diff --git a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataPresenter.kt b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataPresenter.kt index 84dd97073a..72ccbcdfbd 100644 --- a/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataPresenter.kt +++ b/app/src/main/java/org/dhis2/usescases/teiDashboard/dashboardfragments/teidata/TEIDataPresenter.kt @@ -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 @@ -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) diff --git a/app/src/test/java/org/dhis2/usescases/teiDashboard/TeiDashboardPresenterTest.kt b/app/src/test/java/org/dhis2/usescases/teiDashboard/TeiDashboardPresenterTest.kt index f781a95e01..8d7e18bded 100644 --- a/app/src/test/java/org/dhis2/usescases/teiDashboard/TeiDashboardPresenterTest.kt +++ b/app/src/test/java/org/dhis2/usescases/teiDashboard/TeiDashboardPresenterTest.kt @@ -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 @@ -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(), @@ -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)