diff --git a/db/routines/R__018_fn_pv_delta_profile_cache.sql b/db/routines/R__018_fn_pv_delta_profile_cache.sql index 6167269..7cd4295 100644 --- a/db/routines/R__018_fn_pv_delta_profile_cache.sql +++ b/db/routines/R__018_fn_pv_delta_profile_cache.sql @@ -81,14 +81,17 @@ begin from ems.site_pv_forecast_calibration c where c.site_id = p_site_id; + -- ČTENÁŘ NIKDY NEPOČÍTÁ (přepočet = 44 s/site na prod!). Vrací cache bez + -- ohledu na stáří (přepočet řídí výhradně fn_refresh_… — throttle 6 h + -- z fill_forecast_accuracy ticku + denní catch-up). p_max_age ponechán + -- v signatuře kvůli kompatibilitě volajících, ignoruje se. if v_cached is not null - and v_cached_at is not null - and v_cached_at >= now() - p_max_age - and p_data_from >= (now() - interval '120 days') + and p_data_from >= (now() - interval '121 days') and p_data_to <= now() + interval '5 minutes' then return v_cached; end if; + -- jen first-run (cache NULL) nebo nestandardní analytické okno: return ems.fn_pv_forecast_delta_profile( p_site_id, p_data_from, @@ -103,4 +106,4 @@ end; $fn$; comment on function ems.fn_pv_forecast_delta_profile_cached is - 'Delta profil z cache (max 30 min) nebo přepočet; pro canonical PV a /plan/current.'; + 'Delta profil VŽDY z cache (stáří řídí refresh job, ne čtenář — přepočet 44 s/site); inline přepočet jen first-run / nestandardní okno.';