Skip to content

Commit b15b79b

Browse files
dubdabasodubaLentumunai-Markellykits
authored
Map search bug fixes (#3516)
* - Updating the infinite scroll paging - Updating the behaviour after clearing search bar on the maps * - spotless apply * - Fix breaking tests on geo widget module * - Fix tests * - Run spotless * - Import `LazyPagingItems` * - Adding tests * - Update the APK naming * Ignore test to be refactored later Signed-off-by: Elly Kitoto <[email protected]> * - Run spotless * Update kujaku version. Signed-off-by: Lentumunai-Mark <[email protected]> --------- Signed-off-by: Elly Kitoto <[email protected]> Signed-off-by: Lentumunai-Mark <[email protected]> Co-authored-by: Lentumunai Mark <[email protected]> Co-authored-by: Elly Kitoto <[email protected]> Co-authored-by: Lentumunai-Mark <[email protected]>
1 parent 07555fd commit b15b79b

File tree

4 files changed

+60
-12
lines changed

4 files changed

+60
-12
lines changed

android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt

+14-8
Original file line numberDiff line numberDiff line change
@@ -1070,14 +1070,20 @@ constructor(
10701070
if (currentPage != null && pageSize != null) {
10711071
val fromIndex = currentPage * pageSize
10721072
val toIndex = (currentPage + 1) * pageSize
1073-
with(searchResults.subList(fromIndex, min(toIndex, searchResults.size))) {
1074-
mapResourceToRepositoryResourceData(
1075-
relatedResourcesConfig = relatedResourcesConfig,
1076-
configComputedRuleValues = configComputedRuleValues,
1077-
secondaryResourceConfigs = secondaryResourceConfigs,
1078-
filterActiveResources = filterActiveResources,
1079-
baseResourceConfig = baseResourceConfig,
1080-
)
1073+
val maxSublistIndex = min(toIndex, searchResults.size)
1074+
1075+
if (fromIndex < maxSublistIndex) {
1076+
with(searchResults.subList(fromIndex, maxSublistIndex)) {
1077+
mapResourceToRepositoryResourceData(
1078+
relatedResourcesConfig = relatedResourcesConfig,
1079+
configComputedRuleValues = configComputedRuleValues,
1080+
secondaryResourceConfigs = secondaryResourceConfigs,
1081+
filterActiveResources = filterActiveResources,
1082+
baseResourceConfig = baseResourceConfig,
1083+
)
1084+
}
1085+
} else {
1086+
emptyList()
10811087
}
10821088
} else {
10831089
searchResults.mapResourceToRepositoryResourceData(

android/engine/src/test/java/org/smartregister/fhircore/engine/data/local/register/RegisterRepositoryTest.kt

+44
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,50 @@ class RegisterRepositoryTest : RobolectricTest() {
183183
}
184184
}
185185

186+
@Ignore("Refactor this test")
187+
@Test
188+
fun countRegisterDataWithParamsAndRelatedEntityLocationFilter() {
189+
runTest {
190+
val paramsList =
191+
arrayListOf(
192+
ActionParameter(
193+
key = "paramsName",
194+
paramType = ActionParameterType.PARAMDATA,
195+
value = "testing1",
196+
dataType = DataType.STRING,
197+
linkId = null,
198+
),
199+
ActionParameter(
200+
key = "paramName2",
201+
paramType = ActionParameterType.PARAMDATA,
202+
value = "testing2",
203+
dataType = DataType.STRING,
204+
linkId = null,
205+
),
206+
)
207+
paramsList
208+
.asSequence()
209+
.filter { it.paramType == ActionParameterType.PARAMDATA && it.value.isNotEmpty() }
210+
.associate { it.key to it.value }
211+
val paramsMap = emptyMap<String, String>()
212+
val searchSlot = slot<Search>()
213+
every {
214+
registerRepository.retrieveRegisterConfiguration(PATIENT_REGISTER, emptyMap())
215+
} returns
216+
RegisterConfiguration(
217+
appId = "app",
218+
id = PATIENT_REGISTER,
219+
fhirResource = fhirResourceConfig(),
220+
filterDataByRelatedEntityLocation = true,
221+
)
222+
coEvery { fhirEngine.count(capture(searchSlot)) } returns 20
223+
val recordsCount =
224+
registerRepository.countRegisterData(registerId = PATIENT_REGISTER, paramsMap = paramsMap)
225+
Assert.assertEquals(ResourceType.Group, searchSlot.captured.type)
226+
Assert.assertEquals(20, recordsCount)
227+
}
228+
}
229+
186230
@Test
187231
fun testLoadRegisterDataWithForwardAndReverseIncludedResources() =
188232
runTest(timeout = 90.seconds) {

android/gradle/libs.versions.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ kotlinx-coroutines = "1.9.0"
4949
kotlinx-serialization-json = "1.6.0"
5050
kt3k-coveralls-ver="2.12.0"
5151
ktlint = "0.50.0"
52-
kujaku-library = "0.10.6-2-SNAPSHOT"
52+
kujaku-library = "0.10.7-SNAPSHOT"
5353
kujaku-mapbox-sdk-turf = "7.2.0"
5454
leakcanary-android = "2.10"
5555
lifecycle= "2.8.5"

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,7 @@ fun TopScreenSection(
237237
when {
238238
!searchQuery.isBlank() -> {
239239
IconButton(
240-
onClick = {
241-
onSearchTextChanged(SearchQuery.emptyText, performSearchOnValueChanged)
242-
},
240+
onClick = { onSearchTextChanged(SearchQuery.emptyText, true) },
243241
modifier = modifier.testTag(TRAILING_ICON_BUTTON_TEST_TAG),
244242
) {
245243
Icon(

0 commit comments

Comments
 (0)