HOTFIX 2/2: delta profil — čtenář NIKDY nepočítá, jen čte cache
Postřeh uživatele odhalil druhou půlku problému: _cached getter měl max_age 30 min s INLINE fallbackem na plný 44s přepočet — dosud to maskoval 15min refresh; po throttlu refresh jednou za 6 h by KAŽDÉ čtení po vystárnutí cache (plan/current, canonical sloty plánovače) spouštělo 44 s. Čtenář teď vrací cache bez ohledu na stáří; počítá výhradně refresh (throttle 6 h + denní catch-up). Inline jen first-run/analytická okna. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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.';
|
||||
|
||||
Reference in New Issue
Block a user