From 6c42c4bc51f37854c08ae719c0f8b6f33440ccfb Mon Sep 17 00:00:00 2001 From: oleksandrsarapulovgl <82441124+oleksandrsarapulovgl@users.noreply.github.com> Date: Wed, 7 Jul 2021 10:54:06 +0300 Subject: [PATCH] Feature/rules filtering update (#30) * Rules filtering update * Update --- .../app/engine/domain/rules/DefaultGetRulesUseCase.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/engine/src/main/java/dgca/verifier/app/engine/domain/rules/DefaultGetRulesUseCase.kt b/engine/src/main/java/dgca/verifier/app/engine/domain/rules/DefaultGetRulesUseCase.kt index da9ddc1..1f27e93 100644 --- a/engine/src/main/java/dgca/verifier/app/engine/domain/rules/DefaultGetRulesUseCase.kt +++ b/engine/src/main/java/dgca/verifier/app/engine/domain/rules/DefaultGetRulesUseCase.kt @@ -58,16 +58,17 @@ class DefaultGetRulesUseCase(private val rulesRepository: RulesRepository) : Get region: String? ): List { val acceptanceRules = mutableMapOf() + val selectedRegion: String = region?.trim() ?: "" rulesRepository.getRulesBy( acceptanceCountryIsoCode, ZonedDateTime.now().withZoneSameInstant( UTC_ZONE_ID ), Type.ACCEPTANCE, certificateType.toRuleCertificateType() ).forEach { - if (((it.region.isNullOrEmpty() && region.isNullOrEmpty()) - || (it.region?.trim() - .equals(acceptanceCountryIsoCode, ignoreCase = true)) - || (it.region?.trim().equals(region?.trim(), ignoreCase = true)) - ) && (acceptanceRules[it.identifier]?.version?.toVersion() ?: -1 < it.version.toVersion() ?: 0) + val ruleRegion: String = it.region?.trim() ?: "" + if (selectedRegion.equals( + ruleRegion, + ignoreCase = true + ) && (acceptanceRules[it.identifier]?.version?.toVersion() ?: -1 < it.version.toVersion() ?: 0) ) { acceptanceRules[it.identifier] = it }