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

fix: 5634 - refresh of price lazy counters when accessing lists #5678

Merged
merged 4 commits into from
Oct 13, 2024

Conversation

monsieurtanuki
Copy link
Contributor

What

  • About a month ago, we switched to "lazy" counts (e.g. my prices) for the user page: we count only the very first time, or on demand (refresh button).
  • That brings incoherence when we go to the list page and then back to the "counts" page: the lazy count was not explicitly refreshed and kept its old value.
  • The purpose of this PR is to refresh the price lazy counts each time we go to the corresponding list page (that of course computes the latest counts).

Screenshots

For "Derniers prix ajoutés" = latest added prices

lazy 34441 displayed list refreshed lazy 37199
Screenshot_20241009_094803 Screenshot_20241009_094823 Screenshot_20241009_094837

Fixes bug(s)

Impacted files

  • get_prices_model.dart: added a LazyCounterPrices? parameter
  • lazy_counter.dart: added a bool notify parameter
  • lazy_counter_widget.dart: now refreshed by "external" new count
  • price_user_button.dart: added a LazyCounterPrices parameter to have the counter refreshed
  • product_prices_list.dart: now setting the lazy counter when displaying the list
  • user_preferences.dart: added a bool notify parameter for the lazy counter setter
  • user_preferences_account.dart: added a LazyCounterPrices parameter to have the counter refreshed

Impacted files:
* `get_prices_model.dart`: added a `LazyCounterPrices?` parameter
* `lazy_counter.dart`: added a `bool notify` parameter
* `lazy_counter_widget.dart`: now refreshed by "external" new count
* `price_user_button.dart`: added a `LazyCounterPrices` parameter to have the counter refreshed
* `product_prices_list.dart`: now setting the lazy counter when displaying the list
* `user_preferences.dart`: added a `bool notify` parameter for the lazy counter setter
* `user_preferences_account.dart`: added a `LazyCounterPrices` parameter to have the counter refreshed
@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 0% with 25 lines in your changes missing coverage. Please review.

Project coverage is 6.79%. Comparing base (4d9c7fc) to head (c227350).
Report is 357 commits behind head on develop.

Files with missing lines Patch % Lines
...app/lib/pages/preferences/lazy_counter_widget.dart 0.00% 12 Missing ⚠️
.../lib/data_models/preferences/user_preferences.dart 0.00% 5 Missing ⚠️
...ooth_app/lib/pages/prices/product_prices_list.dart 0.00% 5 Missing ⚠️
...smooth_app/lib/pages/preferences/lazy_counter.dart 0.00% 2 Missing ⚠️
...smooth_app/lib/pages/prices/price_user_button.dart 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           develop   #5678      +/-   ##
==========================================
- Coverage     9.54%   6.79%   -2.75%     
==========================================
  Files          325     404      +79     
  Lines        16411   21560    +5149     
==========================================
- Hits          1567    1466     -101     
- Misses       14844   20094    +5250     

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

Copy link
Member

@teolemon teolemon left a comment

Choose a reason for hiding this comment

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

👍 I had spotted this and was mildly annoyed

@monsieurtanuki monsieurtanuki merged commit db080d2 into openfoodfacts:develop Oct 13, 2024
6 checks passed
@monsieurtanuki
Copy link
Contributor Author

Thank you @teolemon for your reviews!

@monsieurtanuki
Copy link
Contributor Author

@teolemon We could even refresh the cached count after each time we add prices, as part of the related background task.
If you find this interesting, please create an issue about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Refresh the cached price counts after accessing the price list pages
3 participants