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 @@ -71,23 +71,15 @@ selectAll:
SELECT * FROM TestDescriptor ORDER BY runId;

selectLatest:
WITH latest AS (
SELECT runId, MAX(date_updated) AS last_date_updated FROM TestDescriptor GROUP BY runId
)
SELECT * FROM TestDescriptor
WHERE runId IN (SELECT runId FROM latest)
AND date_updated IN (SELECT last_date_updated FROM latest)
SELECT * FROM TestDescriptor TD1
WHERE TD1.revision = (SELECT MAX(TD2.revision) FROM TestDescriptor TD2 WHERE TD2.runId = TD1.runId)
ORDER BY runId;

selectLatestByRunIds:
WITH latest AS (
SELECT runId, MAX(date_updated) AS last_date_updated FROM TestDescriptor
WHERE runId IN ?
GROUP BY runId
)
SELECT * FROM TestDescriptor
WHERE runId IN (SELECT runId FROM latest)
AND date_updated IN (SELECT last_date_updated FROM latest);
SELECT * FROM TestDescriptor TD1
WHERE TD1.revision = (SELECT MAX(TD2.revision) FROM TestDescriptor TD2 WHERE TD2.runId = TD1.runId)
AND TD1.runId IN ?
ORDER BY runId;

deleteByRunId:
DELETE FROM TestDescriptor WHERE runId = ?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ class TestDescriptorRepositoryTest {
assertContains(latest, modelB2)
}

@Test
fun listLatestWithSameDateUpdated() =
runTest {
val model1 = DescriptorFactory.buildInstalledModel(
id = InstalledTestDescriptorModel.Id("A"),
revision = 0,
dateUpdated = now().toLocalDateTime(),
)
val model2 = model1.copy(revision = 1)
subject.createOrIgnore(listOf(model1, model2))

val latest = subject.listLatest().first()
assertEquals(1, latest.size)
assertContains(latest, model2)
}

@Test
fun listLatestByRunIds() =
runTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.ooni.probe.domain

import org.ooni.probe.data.models.PreferenceItem
import org.ooni.probe.data.models.SettingsKey

fun organizationPreferenceDefaults(): List<Pair<SettingsKey, Any>> {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ sqldelight-android = { module = "app.cash.sqldelight:android-driver", version.re
sqldelight-native = { module = "app.cash.sqldelight:native-driver", version.ref = "sqldelight" }

# Files
okio = { module = "com.squareup.okio:okio", version = "3.9.1" }
okio = { module = "com.squareup.okio:okio", version = "3.10.2" }

# Lottie animations
kottie = { module = "io.github.alexzhirkevich:compottie", version = "2.0.0-rc01" } # 2.0.0 not supported yet
Expand Down
Loading