ProductOpener::Stats - Compute stats for categories (nutrients, etc.)
This module provides functions to compute and load stats for categories (nutrients, etc.)
This build a collection ($value_ref) were for each nutrients (or other numeric attribute),
$key,
we store the accumulate values for that nutrient (s),
number of instances <n> and each values array).
We will then pass $values_ref to compute_stats_for_products.
Where we will store the stats.
Values for some nutrients (or other numeric values),
with accumulated values and number of products considered (it is different from $n as some products might not have a value).
See add_product_value_to_stats
Including products that have no values for the nutrients we are interested in.
E.g. category ID.
Loads nutrient stats for all categories and countries. If the data is already loaded, it does not reload it unless $force_reload is true.
The stats are displayed on category pages and used in product pages, as well as in data quality checks and improvement opportunity detection.
In integration tests, there are no stats in the data directory, and it is difficult to generate them on the fly as we need to stop and start Apache after to load them, which is complex in the test framework with Docker.
So instead we load them from the test data directory.