Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ooni test descriptors. #275

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft

feat: add ooni test descriptors. #275

wants to merge 12 commits into from

Conversation

aanorbel
Copy link
Member

@aanorbel aanorbel commented Nov 18, 2024

Closes #173, #174

@aanorbel aanorbel marked this pull request as draft November 18, 2024 12:45
@aanorbel aanorbel requested a review from sdsantos December 3, 2024 10:51
@aanorbel aanorbel marked this pull request as ready for review December 3, 2024 10:51
Copy link
Collaborator

@sdsantos sdsantos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel we should remove Defaults descriptors all together. If we don't have them anymore, we don't need the extra complexity. That means:

  • No need to keep both Descriptor and InstalledTestDescriptorModel classes
  • Descriptor.Source is not needed
  • DefaultTestDescriptor is not needed
  • GetDefaultTestDescriptors is not needed
  • Only isDefault() method is needed, the isInstalledNonDefaultDescriptor() should just be !isDefault().

That should simplify a lot of the existing code.

@@ -53,6 +58,21 @@ data class InstalledTestDescriptorModel(

val isExpired get() = expirationDate != null && expirationDate < LocalDateTime.now()

val isDefaultTestDescriptor get() = id.value in 10470..10474 // TODO(aanorbel): switch to OONI reserved namespace

val key get() = if (isDefaultTestDescriptor) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more like a settings key now no? Just to make it clear why we still need this. Because for all other purposes now we can use the ID.

@sdsantos
Copy link
Collaborator

sdsantos commented Dec 3, 2024

I feel we should remove Defaults descriptors all together. If we don't have them anymore, we don't need the extra complexity. That means:

  • No need to keep both Descriptor and InstalledTestDescriptorModel classes
  • Descriptor.Source is not needed
  • DefaultTestDescriptor is not needed
  • GetDefaultTestDescriptors is not needed
  • Only isDefault() method is needed, the isInstalledNonDefaultDescriptor() should just be !isDefault().

That should simplify a lot of the existing code.

Maybe we can keep both Descriptor and InstalledTestDescriptorModel. It may be useful for the updateStatus for example. But there's no need to duplicate fields, we can just have the installed model as a field of the descriptor.

@aanorbel aanorbel requested a review from sdsantos December 4, 2024 07:22
Copy link
Collaborator

@sdsantos sdsantos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a bug. When you just have the OONI descriptors, and no custom descriptor installed, the pull-to-refresh on the Dashboard screen doesn't seem to work. The refresh icon just says at the top without animation.

}
}
companion object {
fun fromDescriptor(descriptor: Descriptor) = descriptor.source.id
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This companion object isn't needed, it should return an object of the type Test, or it should be called something like sourceFromDescriptor. It's weird that a static factory method only returns a specific field inside its class.

@@ -17,24 +17,11 @@ sealed interface RunSpecification {

@Serializable
data class Test(
val source: Source,
val source: InstalledTestDescriptorModel.Id? = null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call this sourceId or descriptorId to avoid confusion?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this should never be null right?

@@ -104,7 +104,6 @@ class ChooseWebsitesViewModel(
RunSpecification.Full(
tests = listOf(
RunSpecification.Test(
source = RunSpecification.Test.Source.Default("websites"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should fetch it from the DB, or hardcode the websites descriptor ID somewhere.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this is empty, it can be removed no?

@aanorbel aanorbel requested a review from sdsantos December 4, 2024 12:14
@@ -52,6 +72,10 @@ data class InstalledTestDescriptorModel(

val isExpired get() = expirationDate != null && expirationDate < LocalDateTime.now()

val isDefaultTestDescriptor get() = id.value in 10470..10474 // TODO(aanorbel): switch to OONI reserved namespace
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also check if they are in OoniTest now.

@aanorbel
Copy link
Member Author

aanorbel commented Dec 9, 2024

This will be done eventually but converting to draft for now. https://openobservatory.slack.com/archives/GKGRFHXT7/p1733782481912289?thread_ts=1733329764.355889&cid=GKGRFHXT7

@aanorbel aanorbel marked this pull request as draft December 9, 2024 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create descriptors for ooni tests.
2 participants