This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only use check-ins of last 15 days (EXPOSUREAPP-5910) (#2752)
* Only use check-ins of last 15 days * Refactor TraceLocation Retention * Fix SubmissionTaskTest.kt * Fix MainActivityViewModelTest.kt * Address PR feedback * Add CheckInRetentionTest.kt and TraceLocationRetentionTest.kt * Add some comments * Add more comments * Fix tests * Load checkInsWithinRetention instead of allCheckIns in ContactDiary, PresenceTracingWarningTask.kt and TraceWarningPackageSyncTool.kt Co-authored-by: harambasicluka <64483219+harambasicluka@users.noreply.github.com> Co-authored-by: Mohamed <mohamed.metwalli@sap.com>
- Loading branch information
1 parent
3d8901d
commit 20db850
Showing
23 changed files
with
353 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...arn-App/src/main/java/de/rki/coronawarnapp/eventregistration/checkins/CheckInRetention.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package de.rki.coronawarnapp.eventregistration.checkins | ||
|
||
import de.rki.coronawarnapp.util.TimeAndDateExtensions.seconds | ||
import org.joda.time.Instant | ||
import java.util.concurrent.TimeUnit | ||
|
||
private const val CHECK_IN_RETENTION_DAYS = 15 | ||
private val CHECK_IN_RETENTION_SECONDS = TimeUnit.DAYS.toSeconds(CHECK_IN_RETENTION_DAYS.toLong()) | ||
|
||
/** | ||
* returns true if the end date of the check-in isn't older than [CHECK_IN_RETENTION_DAYS], otherwise false | ||
*/ | ||
fun CheckIn.isWithinRetention(now: Instant): Boolean { | ||
val retentionThreshold = (now.seconds - CHECK_IN_RETENTION_SECONDS) | ||
return checkInEnd.seconds >= retentionThreshold | ||
} | ||
|
||
/** | ||
* Returns true if a check-in is stale and therefore can be deleted, otherwise false | ||
*/ | ||
fun CheckIn.isOutOfRetention(now: Instant) = !isWithinRetention(now) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...n/java/de/rki/coronawarnapp/eventregistration/storage/retention/TraceLocationRetention.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package de.rki.coronawarnapp.eventregistration.storage.retention | ||
|
||
import de.rki.coronawarnapp.eventregistration.checkins.qrcode.TraceLocation | ||
import de.rki.coronawarnapp.util.TimeAndDateExtensions.seconds | ||
import org.joda.time.Instant | ||
import java.util.concurrent.TimeUnit | ||
|
||
private const val TRACE_LOCATION_RETENTION_DAYS = 15 | ||
private val TRACE_LOCATION_RETENTION_SECONDS = TimeUnit.DAYS.toSeconds(TRACE_LOCATION_RETENTION_DAYS.toLong()) | ||
|
||
/** | ||
* returns true if a trace location either has no end date or has an end date that isn't older than | ||
* [TRACE_LOCATION_RETENTION_DAYS], otherwise false | ||
*/ | ||
fun TraceLocation.isWithinRetention(now: Instant): Boolean { | ||
val retentionThreshold = (now.seconds - TRACE_LOCATION_RETENTION_SECONDS) | ||
return if (endDate == null) { | ||
true | ||
} else { | ||
endDate.seconds >= retentionThreshold | ||
} | ||
} | ||
|
||
/** | ||
* Returns true if a trace location is stale and therefore can be deleted, otherwise false | ||
*/ | ||
fun TraceLocation.isOutOfRetention(now: Instant) = !isWithinRetention(now) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.