Skip to content

Commit

Permalink
Feature/rules filtering update (#30)
Browse files Browse the repository at this point in the history
* Rules filtering update

* Update
  • Loading branch information
oleksandrsarapulovgl authored Jul 7, 2021
1 parent 6e986b2 commit 6c42c4b
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,17 @@ class DefaultGetRulesUseCase(private val rulesRepository: RulesRepository) : Get
region: String?
): List<Rule> {
val acceptanceRules = mutableMapOf<String, Rule>()
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
}
Expand Down

0 comments on commit 6c42c4b

Please sign in to comment.