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

MBL-2135: SearchAndFilter viewmodel #2247

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft

Conversation

Arkariang
Copy link
Contributor

@Arkariang Arkariang commented Mar 5, 2025

📲 What

  • ViewModel now handles be able to search terms

🤔 Why

Some background context on why the change is needed.

🛠 How

  • on VM init debuncing searchterm will trigger the query with specific discovery params

    • if serarch term is empty will return sorting popular results
    • if search terms contains any term will return results for the terms and sorting popular.
      ℹ️ (More sorting and filtering options will be extended in follow up tickets)
  • Reftags added when pressing a project result of a search (either with or without terms, take a look at unit tests if more details required).

  • Analytics events triggered with every search query execution ( 1CTA, 1 PAGE_VIEWED) with the discovery params.
    ℹ️ (PAGE_VIEWD) even will be extended with pagination pages information on following tickets.

  • Error handling via red snackbar with generic error message.

  • CancellationException (within KSApolloClient) is not considered an error, when using collectLatest previous suspend functions/flow emissions will be canceled, this is the expected behaviour as we want to execute networking and update UI only with the most recent params and should not be considered an error that requires user feedback.

👀 See

searchExperience.mp4

| | |

📋 QA

  • Either in staging or production perform some terms searching, when there is no search term a collection of "popular" projects will be presented.
  • Try to navigate to some of the project results live or in prelaunch state.

Story 📖

MBL-2135

* @param selectedProject The project selected by the user.
* @return The project and its appropriate ref tag.
*/
private fun projectAndRefTag(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method has been ported directly from the old search experience.

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 75.90361% with 20 lines in your changes missing coverage. Please review.

Project coverage is 67.71%. Comparing base (2e7adb0) to head (0e8896f).

Files with missing lines Patch % Lines
...tures/search/viewmodel/SearchAndFilterViewModel.kt 83.82% 3 Missing and 8 partials ⚠️
...arter/ui/activities/compose/search/SearchScreen.kt 40.00% 8 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2247      +/-   ##
============================================
+ Coverage     67.69%   67.71%   +0.02%     
- Complexity     2204     2219      +15     
============================================
  Files           360      360              
  Lines         24357    24419      +62     
  Branches       3582     3593      +11     
============================================
+ Hits          16488    16535      +47     
- Misses         5987     5999      +12     
- Partials       1882     1885       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

if (debouncedTerm.isEmpty() || debouncedTerm.isBlank()) {
_params.emit(popularDiscoveryParam)
} else
_params.emit(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In future additions, with category selection or project sort, there will be inputs to this VM (similar to updateSearchTerm) that will add new emissions to _params with each user selection.
In the future will likely not collect searchTerm chain but rather params

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.

2 participants