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

Bug 1919541 - Implement variant handling in the search engine selector. #6536

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

Standard8
Copy link
Member

This implements handling for search engine variants within the selector. It does not handle sub-variants at this time, that will be handled in a follow-up.

No changelog/API entries as this isn't currently used anywhere.

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

Branch builds: add [firefox-android: branch-name] to the PR title.

Copy link

@mandysGit mandysGit left a comment

Choose a reason for hiding this comment

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

Thank you. This looks good. I had a suggestion for renaming the parameters of the merge function and the other parts all look good to me.

Comment on lines 26 to 38
fn merge(self, other: Self) -> Self {
Self {
base: other.base.or(self.base),
method: other.method.or(self.method),
params: other.params.or(self.params),
search_term_param_name: other.search_term_param_name.or(self.search_term_param_name),
}
}
}

Choose a reason for hiding this comment

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

I'm a bit confused with the parameter naming or lack of naming. It's confusing to figure out which Url is overriding the other Url because there's self and other: Self. I know the first one is just referring to the type self which is JSONEngineUrl. It wasn't obvious at first and I had mixed them up.

I'm wondering if we're able to change function definition to any of these?

fn merge(baseUrl: Self, variantUrl: Self) -> Self 

fn merge(baseUrl: Self, overrideUrl: Self) -> Self 

I was reading about Associated Functions and if we change the function definition with a explicit parameter name, then this changes to an associated function and we might need to call it in a different way:
JSONEngineUrl::merge(url1, url2) rather than url1.merge(url2)

My other thought is, if you'll like to keep it as an instance method, maybe rename other to overrideUrl or variantUrl?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about it a bit, and decided to go with associated functions, since they seemed better for what was actually going on - merging two objects & returning a new one (rather than modifying one of them in-place).

I've also switched to using original and preferred as I think that is hopefully clear than base/variant - the merge functions don't care about what is being merged.

@mandysGit
Copy link

mandysGit commented Dec 24, 2024

Question:
I was reading the docs I wrote on variants and sub-variants as a refresher, but it didn't say anything about not matching any sub-variants and what happens in that scenario.

I know this PR isn't about sub-variants, but I was just curious and wanted to verify. If there's a list of sub-variants but none of them match, we match the last top-level variant that was matched. Is that right?

@Standard8 Standard8 removed the request for review from linabutler January 2, 2025 11:57
@Standard8
Copy link
Member Author

I know this PR isn't about sub-variants, but I was just curious and wanted to verify. If there's a list of sub-variants but none of them match, we match the last top-level variant that was matched. Is that right?

If a top-level variant matches, then it is applied, regardless of if there's a matching sub-variant or not. If there is a matching sub-variant, then that will be applied on top i.e. take the base, merge the variant, (maybe) merge the sub-variant.

Copy link
Contributor

@linabutler linabutler left a comment

Choose a reason for hiding this comment

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

Oops, I had these small pending style suggestions, and never submitted them!

components/search/src/filter.rs Outdated Show resolved Hide resolved
components/search/src/filter.rs Outdated Show resolved Hide resolved
@Standard8
Copy link
Member Author

Oops, I had these small pending style suggestions, and never submitted them!

Thank you!

@Standard8 Standard8 added this pull request to the merge queue Jan 7, 2025
Merged via the queue into mozilla:main with commit 5e3fb6c Jan 7, 2025
15 checks passed
@Standard8 Standard8 deleted the search-variant branch January 7, 2025 22:02
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.

3 participants