Skip to content

Commit

Permalink
fixed migrate script
Browse files Browse the repository at this point in the history
  • Loading branch information
navrotskyj committed Sep 29, 2023
1 parent a5695e3 commit 185ad4b
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions store/sqlstore/migration/23.09/23.07-23.09.sql
Original file line number Diff line number Diff line change
Expand Up @@ -646,35 +646,6 @@ END;
$$;



drop FUNCTION call_center.cc_wrap_over_dial;
--
-- Name: cc_wrap_over_dial(numeric, numeric, numeric, numeric, numeric); Type: FUNCTION; Schema: call_center; Owner: -
--

CREATE FUNCTION call_center.cc_wrap_over_dial(over numeric DEFAULT 1, current numeric DEFAULT 0, target numeric DEFAULT 5, max numeric DEFAULT 7, q numeric DEFAULT 10) RETURNS numeric
LANGUAGE plpgsql IMMUTABLE
AS $$
declare dx numeric;
begin
if current >= max then
return 1;
end if;

dx = target - current;
if dx = 0 then
dx = 0.99;
end if;

if dx > 0 then
return over + ( (over * dx * q) / 100 );
else
return (over * (((max - current) * (100 + q )) / max) ) / 100;
end if;
end;
$$;


drop MATERIALIZED VIEW call_center.cc_agent_today_stats;
--
-- Name: cc_agent_today_stats; Type: MATERIALIZED VIEW; Schema: call_center; Owner: -
Expand Down Expand Up @@ -884,6 +855,33 @@ refresh materialized view call_center.cc_agent_today_stats;


drop MATERIALIZED VIEW call_center.cc_distribute_stats;

drop FUNCTION call_center.cc_wrap_over_dial;
--
-- Name: cc_wrap_over_dial(numeric, numeric, numeric, numeric, numeric); Type: FUNCTION; Schema: call_center; Owner: -
--

CREATE FUNCTION call_center.cc_wrap_over_dial(over numeric DEFAULT 1, current numeric DEFAULT 0, target numeric DEFAULT 5, max numeric DEFAULT 7, q numeric DEFAULT 10) RETURNS numeric
LANGUAGE plpgsql IMMUTABLE
AS $$
declare dx numeric;
begin
if current >= max then
return 1;
end if;

dx = target - current;
if dx = 0 then
dx = 0.99;
end if;

if dx > 0 then
return over + ( (over * dx * q) / 100 );
else
return (over * (((max - current) * (100 + q )) / max) ) / 100;
end if;
end;
$$;
--
-- Name: cc_distribute_stats; Type: MATERIALIZED VIEW; Schema: call_center; Owner: -
--
Expand Down

0 comments on commit 185ad4b

Please sign in to comment.