fix graf v sql
This commit is contained in:
@@ -101,8 +101,11 @@ AS $$
|
||||
cbs.avg_power_w + 0.5 * COALESCE(cbs.stddev_power_w, 100),
|
||||
550
|
||||
)::INT AS confidence_w
|
||||
FROM generate_series(p_from, p_to - INTERVAL '15 minutes',
|
||||
INTERVAL '15 minutes') AS gs(slot)
|
||||
FROM generate_series(
|
||||
date_bin(interval '15 minutes', p_from, timestamptz '1970-01-01T00:00:00Z'),
|
||||
date_bin(interval '15 minutes', p_to, timestamptz '1970-01-01T00:00:00Z') - interval '15 minutes',
|
||||
interval '15 minutes'
|
||||
) AS gs(slot)
|
||||
LEFT JOIN ems.consumption_baseline_stats cbs
|
||||
ON cbs.site_id = p_site_id
|
||||
AND cbs.day_of_week = EXTRACT(DOW FROM gs.slot AT TIME ZONE 'Europe/Prague')::INT
|
||||
|
||||
@@ -11,11 +11,11 @@ stable
|
||||
as $fn$
|
||||
with bounds as (
|
||||
select
|
||||
p_from as ts_from,
|
||||
date_bin(interval '15 minutes', p_from, timestamptz '1970-01-01T00:00:00Z') as ts_from,
|
||||
case
|
||||
when p_to <= p_from then p_from + interval '15 minutes'
|
||||
when p_to > p_from + interval '60 days' then p_from + interval '60 days'
|
||||
else p_to
|
||||
when p_to <= p_from then date_bin(interval '15 minutes', p_from, timestamptz '1970-01-01T00:00:00Z') + interval '15 minutes'
|
||||
when p_to > p_from + interval '60 days' then date_bin(interval '15 minutes', p_from, timestamptz '1970-01-01T00:00:00Z') + interval '60 days'
|
||||
else date_bin(interval '15 minutes', p_to, timestamptz '1970-01-01T00:00:00Z')
|
||||
end as ts_to
|
||||
),
|
||||
slot_spine as (
|
||||
|
||||
@@ -23,11 +23,11 @@ as $fn$
|
||||
),
|
||||
bounds as (
|
||||
select
|
||||
p_from as ts_from,
|
||||
date_bin(interval '15 minutes', p_from, timestamptz '1970-01-01T00:00:00Z') as ts_from,
|
||||
case
|
||||
when p_to <= p_from then p_from + interval '15 minutes'
|
||||
when p_to > p_from + interval '60 days' then p_from + interval '60 days'
|
||||
else p_to
|
||||
when p_to <= p_from then date_bin(interval '15 minutes', p_from, timestamptz '1970-01-01T00:00:00Z') + interval '15 minutes'
|
||||
when p_to > p_from + interval '60 days' then date_bin(interval '15 minutes', p_from, timestamptz '1970-01-01T00:00:00Z') + interval '60 days'
|
||||
else date_bin(interval '15 minutes', p_to, timestamptz '1970-01-01T00:00:00Z')
|
||||
end as ts_to
|
||||
),
|
||||
slot_spine as (
|
||||
|
||||
Reference in New Issue
Block a user