Skip to content

Commit

Permalink
chore: refactoring
Browse files Browse the repository at this point in the history
* refactor: adjust code

* chore: rename variable

Co-authored-by: Kaizen <42545336+Kaizen-7@users.noreply.github.com>
  • Loading branch information
nicola-95 and Kaizen-7 authored Mar 7, 2022
1 parent cf5f413 commit 7880b5d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ data class CertificateModel(
var exemptions: List<Exemption>? = null,
var isBlackListed: Boolean = false,
var scanMode: ScanMode? = null,
var isPreviousScanModeBooster: Boolean = false,
var certificateIdentifier: String = "",
var certificate: Certificate? = null
) {
Expand Down Expand Up @@ -115,7 +114,8 @@ data class TestModel(
val countryOfVaccination: String,
val certificateIssuer: String,
val certificateIdentifier: String,
val resultType: TestResult
val resultType: TestResult,
var isPreviousScanModeBooster: Boolean = false
) : CertificateData

enum class TestResult(val value: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.json.JSONObject
import java.security.cert.Certificate
import java.security.cert.X509Certificate
import java.util.*
import javax.inject.Inject

Expand Down Expand Up @@ -205,7 +204,9 @@ class VerificationViewModel @Inject constructor(
val certificateModel = greenCertificate.toCertificateModel(verificationResult).apply {
isBlackListed = blackListCheckResult
isRevoked = isCertificateRevoked(certificateIdentifier.sha256())
this.isPreviousScanModeBooster = scanMode == ScanMode.BOOSTER
tests?.let {
it.last().isPreviousScanModeBooster = scanMode == ScanMode.BOOSTER
}
this.scanMode = if (getDoubleScanFlag()) ScanMode.DOUBLE_SCAN else scanMode
this.certificateIdentifier = certificateIdentifier
this.certificate = certificate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class TestValidationStrategy : ValidationStrategy {
override fun checkCertificate(certificateModel: CertificateModel, ruleSet: RuleSet): CertificateStatus {
val test: TestModel = certificateModel.tests!!.first()
val scanMode = certificateModel.scanMode
val isPreviousScanModeBooster = certificateModel.isPreviousScanModeBooster
val isADoubleScanBoosterTest = test.isPreviousScanModeBooster
val isTestNotAllowed = (scanMode == ScanMode.BOOSTER) || scanMode == ScanMode.STRENGTHENED || scanMode == ScanMode.SCHOOL

if (test.resultType == TestResult.DETECTED) {
Expand All @@ -61,7 +61,7 @@ class TestValidationStrategy : ValidationStrategy {
TestType.MOLECULAR.value -> {
startDate = ldtDateTimeOfCollection.plusHours(ruleSet.getMolecularTestStartHour())
endDate =
if (scanMode == ScanMode.DOUBLE_SCAN && isPreviousScanModeBooster)
if (scanMode == ScanMode.DOUBLE_SCAN && isADoubleScanBoosterTest)
ldtDateTimeOfCollection.plusHours(ruleSet.getRapidTestEndHour())
else
ldtDateTimeOfCollection.plusHours(ruleSet.getMolecularTestEndHour())
Expand Down

0 comments on commit 7880b5d

Please sign in to comment.