(select -1 as id, %(oc_id)s as oc_id, %(zero_point)s as zero_point, %(span_value)s as span_value, %(gas_concentration)s as gas_concentration, %(timestamp)s as timestamp, 'generated' as createdby)
union
select * from scaling_points where timestamp <> %(old_timestamp)s
)
)
"""
elifscalingpoint["use_scalingpoint"]==False:
with_sql="""
with scaling_points as (
with scaling_points as (
select * from scaling_points where timestamp <> %(timestamp)s
)
)
"""
model=scalingpoint
model["sampling_point_id"]=sampling_point_id
sql="""
select
f.oc_id as f_oc_id,
f.zero_point as f_zero_point,
f.span_value as f_span_value,
select
f.oc_id as f_oc_id,
f.zero_point as f_zero_point,
f.span_value as f_span_value,
f.gas_concentration as f_gas_concentration,
f.timestamp as f_timestamp,
extract(epoch from f.timestamp)*1000 as f_timestamp_number,
t.oc_id as t_oc_id,
t.zero_point as t_zero_point,
t.span_value as t_span_value,
t.oc_id as t_oc_id,
t.zero_point as t_zero_point,
t.span_value as t_span_value,
t.gas_concentration as t_gas_concentration,
t.timestamp as t_timestamp,
extract(epoch from t.timestamp)*1000 as t_timestamp_number
from
(
select a.*, lead(a.id) over (order by a.timestamp asc) as next