planner v2 vc. porovnani
This commit is contained in:
@@ -5,7 +5,8 @@ create or replace function ems.fn_planning_run_commit(
|
||||
p_horizon_start timestamptz,
|
||||
p_horizon_end timestamptz,
|
||||
p_run_meta jsonb,
|
||||
p_intervals jsonb
|
||||
p_intervals jsonb,
|
||||
p_activate_run boolean default true
|
||||
)
|
||||
returns int
|
||||
language plpgsql
|
||||
@@ -29,7 +30,7 @@ begin
|
||||
p_site_id,
|
||||
p_horizon_start,
|
||||
p_horizon_end,
|
||||
'draft',
|
||||
case when p_activate_run then 'draft' else 'comparison' end,
|
||||
nullif(trim(p_run_meta->>'run_type'), ''),
|
||||
nullif(trim(p_run_meta->>'triggered_by'), ''),
|
||||
case
|
||||
@@ -128,13 +129,16 @@ begin
|
||||
|
||||
update ems.planning_run
|
||||
set status = 'superseded'
|
||||
where site_id = p_site_id
|
||||
where p_activate_run
|
||||
and site_id = p_site_id
|
||||
and status = 'active'
|
||||
and id <> v_run_id;
|
||||
|
||||
update ems.planning_run
|
||||
set status = 'active'
|
||||
where id = v_run_id;
|
||||
if p_activate_run then
|
||||
update ems.planning_run
|
||||
set status = 'active'
|
||||
where id = v_run_id;
|
||||
end if;
|
||||
|
||||
return v_run_id;
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user