fix prices reloading
This commit is contained in:
8
db/migration/V066__site_market_config_validity_index.sql
Normal file
8
db/migration/V066__site_market_config_validity_index.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
-- ============================================================
|
||||
-- Site market config: urychlení lookupu platné konfigurace
|
||||
-- (vw_site_effective_price, fn_effective_*_price)
|
||||
-- ============================================================
|
||||
|
||||
create index if not exists idx_site_market_config_site_valid_from
|
||||
on ems.site_market_config (site_id, valid_from desc);
|
||||
|
||||
@@ -6,6 +6,11 @@ returns jsonb
|
||||
language sql
|
||||
stable
|
||||
as $fn$
|
||||
with bounds as (
|
||||
select
|
||||
((p_day::timestamp) at time zone 'Europe/Prague') as day_start_utc,
|
||||
(((p_day + 1)::timestamp) at time zone 'Europe/Prague') as day_end_utc
|
||||
)
|
||||
select coalesce(
|
||||
jsonb_agg(u.j order by u.interval_start),
|
||||
'[]'::jsonb
|
||||
@@ -17,8 +22,10 @@ as $fn$
|
||||
from (
|
||||
select v.*
|
||||
from ems.vw_site_effective_price v
|
||||
cross join bounds b
|
||||
where v.site_id = p_site_id
|
||||
and (v.interval_start at time zone 'Europe/Prague')::date = p_day
|
||||
and v.interval_start >= b.day_start_utc
|
||||
and v.interval_start < b.day_end_utc
|
||||
order by v.interval_start
|
||||
) t
|
||||
) u;
|
||||
|
||||
Reference in New Issue
Block a user