Skip to content

Commit

Permalink
fix: [ANDROAPP-6277] Working lists not filtering search results
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo <[email protected]>
  • Loading branch information
Balcan committed Jun 27, 2024
1 parent ce20719 commit 0137136
Showing 1 changed file with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,27 @@ class SearchRepositoryImplKt(
searchParametersModel: SearchParametersModel,
isOnline: Boolean,
): TrackedEntitySearchCollectionRepository {
var allowCache = false

if (searchParametersModel != searchRepositoryJava.savedSearchParameters || !FilterManager.getInstance()
.sameFilters(searchRepositoryJava.savedFilters)
) {
trackedEntityInstanceQuery =
searchRepositoryJava.getFilteredRepository(searchParametersModel)
} else {
trackedEntityInstanceQuery =
searchRepositoryJava.getFilteredRepository(searchParametersModel)
allowCache = true
}

if (searchRepositoryJava.fetchedTeiUIDs.isNotEmpty() && searchParametersModel.selectedProgram == null) {
trackedEntityInstanceQuery =
trackedEntityInstanceQuery.excludeUids().`in`(searchRepositoryJava.fetchedTeiUIDs.toList())
val allowCache = !(
searchParametersModel != searchRepositoryJava.savedSearchParameters ||
!FilterManager.getInstance().sameFilters(searchRepositoryJava.savedFilters)
)

if (
searchRepositoryJava.fetchedTeiUIDs.isNotEmpty() &&
searchParametersModel.selectedProgram == null
) {
trackedEntityInstanceQuery = trackedEntityInstanceQuery.excludeUids()
.`in`(searchRepositoryJava.fetchedTeiUIDs.toList())
}

val pagerFlow = if (isOnline && FilterManager.getInstance().stateFilters.isEmpty()) {
return if (isOnline && FilterManager.getInstance().stateFilters.isEmpty()) {
trackedEntityInstanceQuery.allowOnlineCache().eq(allowCache).offlineFirst()
} else {
trackedEntityInstanceQuery.allowOnlineCache().eq(allowCache).offlineOnly()
}

return pagerFlow
}

override suspend fun searchParameters(
Expand Down

0 comments on commit 0137136

Please sign in to comment.