Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ import com.mifos.core.data.repository.SavingsAccountSummaryRepository
import com.mifos.core.data.repository.SavingsAccountTransactionReceiptRepository
import com.mifos.core.data.repository.SavingsAccountTransactionRepository
import com.mifos.core.data.repository.SearchRecordRepository
import com.mifos.core.data.repository.SearchRepository
import com.mifos.core.data.search.SearchRepository
import com.mifos.core.data.search.impl.SearchRepositoryImpl
import com.mifos.core.data.repository.ShareAccountRepository
import com.mifos.core.data.repository.SignatureRepository
import com.mifos.core.data.repository.SurveyListRepository
Expand Down Expand Up @@ -136,7 +137,6 @@ import com.mifos.core.data.repositoryImp.SavingsAccountSummaryRepositoryImp
import com.mifos.core.data.repositoryImp.SavingsAccountTransactionReceiptRepositoryImpl
import com.mifos.core.data.repositoryImp.SavingsAccountTransactionRepositoryImp
import com.mifos.core.data.repositoryImp.SearchRecordRepositoryImpl
import com.mifos.core.data.repositoryImp.SearchRepositoryImp
import com.mifos.core.data.repositoryImp.ShareAccountRepositoryImpl
import com.mifos.core.data.repositoryImp.SignatureRepositoryImp
import com.mifos.core.data.repositoryImp.SurveyListRepositoryImp
Expand All @@ -163,7 +163,7 @@ val RepositoryModule = module {
single<CoroutineDispatcher> { get(named(MifosDispatchers.IO.name)) }

singleOf(::LoginRepositoryImpl) bind LoginRepository::class
singleOf(::SearchRepositoryImp) bind SearchRepository::class
singleOf(::SearchRepositoryImpl) bind SearchRepository::class

// Client
singleOf(::ClientDetailsRepositoryImp) bind ClientDetailsRepository::class
Expand Down Expand Up @@ -237,7 +237,6 @@ val RepositoryModule = module {
singleOf(::PathTrackingRepositoryImp) bind PathTrackingRepository::class
singleOf(::ReportCategoryRepositoryImp) bind ReportCategoryRepository::class
singleOf(::ReportDetailRepositoryImp) bind ReportDetailRepository::class
singleOf(::SearchRepositoryImp) bind SearchRepository::class
singleOf(::SignatureRepositoryImp) bind SignatureRepository::class
singleOf(::SurveyListRepositoryImp) bind SurveyListRepository::class
singleOf(::SurveySubmitRepositoryImp) bind SurveySubmitRepository::class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class RoomSubmitOutbox<P>(
override suspend fun deleteAll() =
dao.deleteAll()

private fun DraftEntity.toEntry(): SubmitOutboxEntry<P>? = runCatching {
private fun DraftEntity.toEntry(): SubmitOutboxEntry<P>? = try {
SubmitOutboxEntry(
id = id,
formKey = formKey,
Expand All @@ -96,7 +96,9 @@ class RoomSubmitOutbox<P>(
createdAtMs = createdAtMs,
errorMessage = errorMessage,
)
}.getOrNull()
} catch (_: Throwable) {
null
}
}

private fun currentTimeMillis(): Long = kotlin.time.Clock.System.now().toEpochMilliseconds()

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@
*
* See https://github.com/openMF/mifos-x-field-officer-app/blob/master/LICENSE.md
*/
package com.mifos.core.data.repository
package com.mifos.core.data.search

import com.mifos.core.common.utils.DataState
import com.mifos.core.model.objects.SearchedEntity
import kotlinx.coroutines.flow.Flow

/**
* Created by Aditya Gupta on 06/08/23.
*/
interface SearchRepository {

fun searchResources(
/**
* Query-driven search. Each call returns fresh results (no caching, no Store —
* search results are ephemeral). Throws on transport / HTTP failure.
*/
suspend fun searchResources(
query: String,
resources: String?,
exactMatch: Boolean?,
): Flow<DataState<List<SearchedEntity>>>
): List<SearchedEntity>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mifos-x-field-officer-app/blob/master/LICENSE.md
*/
package com.mifos.core.data.search.impl

import com.mifos.core.data.search.SearchRepository
import com.mifos.core.model.objects.SearchedEntity
import com.mifos.core.network.search.api.SearchApi

class SearchRepositoryImpl(
private val searchApi: SearchApi,
) : SearchRepository {

override suspend fun searchResources(
query: String,
resources: String?,
exactMatch: Boolean?,
): List<SearchedEntity> = searchApi.searchResources(query, resources, exactMatch)
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
/*
* Copyright 2024 Mifos Initiative
* Copyright 2025 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mifos-x-field-officer-app/blob/master/LICENSE.md
*/
package com.mifos.feature.search
package com.mifos.core.data.store

import com.mifos.core.model.objects.SearchedEntity

data class SearchUiState(
val isLoading: Boolean = false,
val error: String? = null,
val searchedEntities: List<SearchedEntity> = emptyList(),
)
typealias ScreenState<T> = template.core.base.store.screen.ScreenState<T>
typealias DataFreshness = template.core.base.store.screen.DataFreshness
typealias ScreenDataStream<T> = template.core.base.store.screen.ScreenDataStream<T>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import kotlinx.coroutines.flow.Flow
class DataManagerSearch(
private val baseApiManager: BaseApiManager,
) {
@Deprecated(
message = "Use com.mifos.core.network.search.api.SearchApi.searchResources instead",
level = DeprecationLevel.WARNING,
)
fun searchResources(
query: String,
resource: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.mifos.core.network.auth.api.createAuthApi
import com.mifos.core.network.center.api.createCenterApi
import com.mifos.core.network.client.api.createClientApi
import com.mifos.core.network.group.api.createGroupApi
import com.mifos.core.network.search.api.createSearchApi
import com.mifos.core.network.utils.FlowConverterFactory
import de.jensklingenberg.ktorfit.Ktorfit
import io.ktor.client.HttpClient
Expand Down Expand Up @@ -67,4 +68,5 @@ val NetworkModule = module {
single { get<Ktorfit>().createClientApi() }
single { get<Ktorfit>().createCenterApi() }
single { get<Ktorfit>().createGroupApi() }
single { get<Ktorfit>().createSearchApi() }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2025 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/mifos-x-field-officer-app/blob/master/LICENSE.md
*/
package com.mifos.core.network.search.api

import com.mifos.core.model.objects.SearchedEntity
import com.mifos.room.basemodel.APIEndPoint
import de.jensklingenberg.ktorfit.http.GET
import de.jensklingenberg.ktorfit.http.Query

/**
* Fineract `search` endpoint. Query-driven, no caching — each call returns fresh results.
*/
interface SearchApi {

@GET(APIEndPoint.SEARCH)
suspend fun searchResources(
@Query("query") query: String,
@Query("resource") resource: String?,
@Query("exactMatch") exactMatch: Boolean?,
): List<SearchedEntity>
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import kotlinx.coroutines.flow.Flow
*/
interface SearchService {

@Deprecated(
message = "Use com.mifos.core.network.search.api.SearchApi.searchResources instead",
level = DeprecationLevel.WARNING,
)
@GET(APIEndPoint.SEARCH)
fun searchResources(
@Query("query") query: String,
Expand Down
3 changes: 2 additions & 1 deletion feature/search/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ kotlin {
implementation(compose.material3)
implementation(compose.components.resources)
implementation(compose.ui)
api(projects.core.domain)
implementation(projects.core.data)
implementation(projects.core.ui)
implementation(compose.components.uiToolingPreview)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@
<string name="feature_search_filter_options_loans_value" translatable="false">loans</string>
<string name="feature_search_filter_options_savings_label">Savings Accounts</string>
<string name="feature_search_filter_options_savings_value" translatable="false">savingsaccounts</string>

<string name="feature_search_a11y_search_icon">Search</string>
<string name="feature_search_a11y_filter_dropdown">Open filter</string>
<string name="feature_search_a11y_perform_search">Perform search</string>
</resources>
Loading
Loading