Skip to content

Commit

Permalink
Results: Show success, anomaly and failed counts on items
Browse files Browse the repository at this point in the history
  • Loading branch information
sdsantos committed Dec 10, 2024
1 parent 12d82a0 commit 1679a7a
Show file tree
Hide file tree
Showing 15 changed files with 332 additions and 80 deletions.
10 changes: 10 additions & 0 deletions composeApp/src/commonMain/composeResources/drawable/ic_world.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q614,800 707,707Q800,614 800,480Q800,473 799.5,465.5Q799,458 799,453Q794,482 772,501Q750,520 720,520L640,520Q607,520 583.5,496.5Q560,473 560,440L560,400L400,400L400,320Q400,287 423.5,263.5Q447,240 480,240L520,240L520,240Q520,217 532.5,199.5Q545,182 563,171Q543,166 522.5,163Q502,160 480,160Q346,160 253,253Q160,346 160,480Q160,480 160,480Q160,480 160,480L360,480Q426,480 473,527Q520,574 520,640L520,680L400,680L400,790Q420,795 439.5,797.5Q459,800 480,800Z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@
<string name="TestResults_Overview_Hero_Tests">Tests</string>
<string name="TestResults_Overview_Hero_Networks">Networks</string>
<string name="TestResults_Overview_Hero_DataUsage">Data Usage</string>
<string name="TestResults_Overview_Websites_Blocked_Singular">%1$s blocked</string>
<string name="TestResults_Overview_Websites_Blocked_Plural">%1$s blocked</string>
<string name="TestResults_Overview_Websites_Tested_Singular">%1$s tested</string>
<string name="TestResults_Overview_Websites_Tested_Plural">%1$s tested</string>
<string name="TestResults_Overview_InstantMessaging_Blocked_Singular">%1$s blocked</string>
<string name="TestResults_Overview_InstantMessaging_Blocked_Plural">%1$s blocked</string>
<string name="TestResults_Overview_InstantMessaging_Available_Singular">%1$s accessible</string>
<string name="TestResults_Overview_InstantMessaging_Available_Plural">%1$s accessible</string>
<string name="TestResults_Overview_Circumvention_Blocked_Singular">%1$s blocked</string>
<string name="TestResults_Overview_Circumvention_Blocked_Plural">%1$s blocked</string>
<string name="TestResults_Overview_Circumvention_Available_Singular">%1$s available</string>
<string name="TestResults_Overview_Circumvention_Available_Plural">%1$s available</string>
<string name="TestResults_Summary_Hero_DateAndTime">Date &amp; Time</string>
<string name="TestResults_Summary_Hero_Network">Network</string>
<string name="TestResults_Summary_Hero_Country">Country</string>
Expand Down Expand Up @@ -302,13 +314,13 @@
<string name="AddDescriptor_Toasts_Unsupported_Url">Unsupported URL</string>

<string name="Measurement_Title">Measurement</string>

<string name="Measurements_Count_One">%1$d measurement</string>
<string name="Measurements_Count_Other">%1$d measurements</string>

<string name="Measurements_Failed">Failed</string>
<string name="Measurements_Ok">OK</string>
<string name="Measurements_Anomaly">Anomaly</string>
<string name="Measurements_Count_One">%1$d measured</string>
<string name="Measurements_Count_Other">%1$d measured</string>
<string name="Measurements_Failed_One">%1$d failed</string>
<string name="Measurements_Failed_Other">%1$d failed</string>

<string name="Results_TestType_All">All Types</string>
<string name="Results_TaskOrigin_All">All Sources</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<resources>
<string name="shareEmailTo" translatable="false">[email protected]</string>
<string name="shareSubject" translatable="false">[bug-report] OONI Probe %1$s</string>
<string name="version" translatable="false">%1$s: %2$s</string>

<plurals name="Common_Minutes" translatable="false">
<item quantity="one">@string/Common_Minutes_One</item>
<item quantity="other">@string/Common_Minutes_Other</item>
</plurals>
<plurals name="Common_Hours" translatable="false">
<item quantity="one">@string/Common_Hour_One</item>
<item quantity="other">@string/Common_Hour_Other</item>
</plurals>

<plurals name="Dashboard_RunTests_RunButton_Label" translatable="false">
<item quantity="one">@string/Dashboard_RunTests_RunButton_Label_One</item>
<item quantity="other">@string/Dashboard_RunTests_RunButton_Label_Other</item>
</plurals>

<plurals name="TestResults_Overview_Websites_Blocked" translatable="false">
<item quantity="one">@string/TestResults_Overview_Websites_Blocked_Singular</item>
<item quantity="other">@string/TestResults_Overview_Websites_Blocked_Plural</item>
</plurals>

<plurals name="TestResults_Overview_Websites_Tested" translatable="false">
<item quantity="one">@string/TestResults_Overview_Websites_Tested_Singular</item>
<item quantity="other">@string/TestResults_Overview_Websites_Tested_Plural</item>
</plurals>

<plurals name="TestResults_Overview_InstantMessaging_Blocked" translatable="false">
<item quantity="one">@string/TestResults_Overview_InstantMessaging_Blocked_Singular</item>
<item quantity="other">@string/TestResults_Overview_InstantMessaging_Blocked_Plural</item>
</plurals>

<plurals name="TestResults_Overview_InstantMessaging_Available" translatable="false">
<item quantity="one">@string/TestResults_Overview_InstantMessaging_Available_Singular</item>
<item quantity="other">@string/TestResults_Overview_InstantMessaging_Available_Plural</item>
</plurals>

<plurals name="TestResults_Overview_Circumvention_Blocked" translatable="false">
<item quantity="one">@string/TestResults_Overview_Circumvention_Blocked_Singular</item>
<item quantity="other">@string/TestResults_Overview_Circumvention_Blocked_Plural</item>
</plurals>

<plurals name="TestResults_Overview_Circumvention_Available" translatable="false">
<item quantity="one">@string/TestResults_Overview_Circumvention_Available_Singular</item>
<item quantity="other">@string/TestResults_Overview_Circumvention_Available_Plural</item>
</plurals>

<plurals name="Measurements_Count" translatable="false">
<item quantity="one">@string/Measurements_Count_One</item>
<item quantity="other">@string/Measurements_Count_Other</item>
</plurals>

<plurals name="Measurements_Failed" translatable="false">
<item quantity="one">@string/Measurements_Failed_One</item>
<item quantity="other">@string/Measurements_Failed_Other</item>
</plurals>
</resources>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ data class ResultListItem(
val result: ResultModel,
val descriptor: Descriptor,
val network: NetworkModel?,
val measurementsCount: Long,
val doneMeasurementsCount: Long,
val failedMeasurementsCount: Long,
val anomalyMeasurementsCount: Long,
val allMeasurementsUploaded: Boolean,
val anyMeasurementUploadFailed: Boolean,
) {
val idOrThrow get() = result.idOrThrow
val idOrThrow
get() = result.idOrThrow
val successMeasurementsCount
get() = doneMeasurementsCount - failedMeasurementsCount - anomalyMeasurementsCount
val testedMeasurementsCount
get() = doneMeasurementsCount - failedMeasurementsCount
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package org.ooni.probe.data.models
data class ResultWithNetworkAndAggregates(
val result: ResultModel,
val network: NetworkModel?,
val measurementsCount: Long,
val doneMeasurementsCount: Long,
val failedMeasurementsCount: Long,
val anomalyMeasurementsCount: Long,
val allMeasurementsUploaded: Boolean,
val anyMeasurementUploadFailed: Boolean,
)
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ class ResultRepository(
network_type = network_type,
).toModel()
},
measurementsCount = measurementsCount,
doneMeasurementsCount = doneMeasurementsCount,
failedMeasurementsCount = failedMeasurementsCount,
anomalyMeasurementsCount = anomalyMeasurementsCount,
allMeasurementsUploaded = allMeasurementsUploaded,
anyMeasurementUploadFailed = anyMeasurementUploadFailed,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class GetResults(
result = item.result,
descriptor = descriptors.forResult(item.result) ?: return@mapNotNull null,
network = item.network,
measurementsCount = item.measurementsCount,
doneMeasurementsCount = item.doneMeasurementsCount,
failedMeasurementsCount = item.failedMeasurementsCount,
anomalyMeasurementsCount = item.anomalyMeasurementsCount,
allMeasurementsUploaded = item.allMeasurementsUploaded,
anyMeasurementUploadFailed = item.anyMeasurementUploadFailed,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,21 @@ import ooniprobe.composeapp.generated.resources.Dashboard_RunTests_RunButton_Lab
import ooniprobe.composeapp.generated.resources.Dashboard_RunTests_RunButton_Label_Other
import ooniprobe.composeapp.generated.resources.Measurements_Count_One
import ooniprobe.composeapp.generated.resources.Measurements_Count_Other
import ooniprobe.composeapp.generated.resources.Measurements_Failed_One
import ooniprobe.composeapp.generated.resources.Measurements_Failed_Other
import ooniprobe.composeapp.generated.resources.Res
import ooniprobe.composeapp.generated.resources.TestResults_Overview_Circumvention_Available_Plural
import ooniprobe.composeapp.generated.resources.TestResults_Overview_Circumvention_Available_Singular
import ooniprobe.composeapp.generated.resources.TestResults_Overview_Circumvention_Blocked_Plural
import ooniprobe.composeapp.generated.resources.TestResults_Overview_Circumvention_Blocked_Singular
import ooniprobe.composeapp.generated.resources.TestResults_Overview_InstantMessaging_Available_Plural
import ooniprobe.composeapp.generated.resources.TestResults_Overview_InstantMessaging_Available_Singular
import ooniprobe.composeapp.generated.resources.TestResults_Overview_InstantMessaging_Blocked_Plural
import ooniprobe.composeapp.generated.resources.TestResults_Overview_InstantMessaging_Blocked_Singular
import ooniprobe.composeapp.generated.resources.TestResults_Overview_Websites_Blocked_Plural
import ooniprobe.composeapp.generated.resources.TestResults_Overview_Websites_Blocked_Singular
import ooniprobe.composeapp.generated.resources.TestResults_Overview_Websites_Tested_Plural
import ooniprobe.composeapp.generated.resources.TestResults_Overview_Websites_Tested_Singular
import org.jetbrains.compose.resources.PluralStringResource
import org.jetbrains.compose.resources.getPluralString
import org.jetbrains.compose.resources.getString
Expand All @@ -37,25 +51,38 @@ val stringMap = mapOf(
"@string/Dashboard_RunTests_RunButton_Label_Other" to Res.string.Dashboard_RunTests_RunButton_Label_Other,
"@string/Measurements_Count_One" to Res.string.Measurements_Count_One,
"@string/Measurements_Count_Other" to Res.string.Measurements_Count_Other,
"@string/Measurements_Failed_One" to Res.string.Measurements_Failed_One,
"@string/Measurements_Failed_Other" to Res.string.Measurements_Failed_Other,
"@string/TestResults_Overview_Websites_Blocked_Singular" to Res.string.TestResults_Overview_Websites_Blocked_Singular,
"@string/TestResults_Overview_Websites_Blocked_Plural" to Res.string.TestResults_Overview_Websites_Blocked_Plural,
"@string/TestResults_Overview_Websites_Tested_Singular" to Res.string.TestResults_Overview_Websites_Tested_Singular,
"@string/TestResults_Overview_Websites_Tested_Plural" to Res.string.TestResults_Overview_Websites_Tested_Plural,
"@string/TestResults_Overview_InstantMessaging_Blocked_Singular" to Res.string.TestResults_Overview_InstantMessaging_Blocked_Singular,
"@string/TestResults_Overview_InstantMessaging_Blocked_Plural" to Res.string.TestResults_Overview_InstantMessaging_Blocked_Plural,
"@string/TestResults_Overview_InstantMessaging_Available_Singular" to Res.string.TestResults_Overview_InstantMessaging_Available_Singular,
"@string/TestResults_Overview_InstantMessaging_Available_Plural" to Res.string.TestResults_Overview_InstantMessaging_Available_Plural,
"@string/TestResults_Overview_Circumvention_Blocked_Singular" to Res.string.TestResults_Overview_Circumvention_Blocked_Singular,
"@string/TestResults_Overview_Circumvention_Blocked_Plural" to Res.string.TestResults_Overview_Circumvention_Blocked_Plural,
"@string/TestResults_Overview_Circumvention_Available_Singular" to Res.string.TestResults_Overview_Circumvention_Available_Singular,
"@string/TestResults_Overview_Circumvention_Available_Plural" to Res.string.TestResults_Overview_Circumvention_Available_Plural,
)

@Composable
fun stringMonthArrayResource(): List<String> {
return listOf(
stringResource(Res.string.Common_Months_January),
stringResource(Res.string.Common_Months_February),
stringResource(Res.string.Common_Months_March),
stringResource(Res.string.Common_Months_April),
stringResource(Res.string.Common_Months_May),
stringResource(Res.string.Common_Months_June),
stringResource(Res.string.Common_Months_July),
stringResource(Res.string.Common_Months_August),
stringResource(Res.string.Common_Months_September),
stringResource(Res.string.Common_Months_October),
stringResource(Res.string.Common_Months_November),
stringResource(Res.string.Common_Months_December),
)
}
fun stringMonthArrayResource(): List<String> =
listOf(
Res.string.Common_Months_January,
Res.string.Common_Months_February,
Res.string.Common_Months_March,
Res.string.Common_Months_April,
Res.string.Common_Months_May,
Res.string.Common_Months_June,
Res.string.Common_Months_July,
Res.string.Common_Months_August,
Res.string.Common_Months_September,
Res.string.Common_Months_October,
Res.string.Common_Months_November,
Res.string.Common_Months_December,
).map { stringResource(it) }

@Composable
fun pluralStringResourceItem(
Expand Down
Loading

0 comments on commit 1679a7a

Please sign in to comment.