-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #297 from dmitry-sinina/1.6cp3
1.6cp3
- Loading branch information
Showing
21 changed files
with
397 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
app/controllers/api/rest/admin/routing/area_prefixes_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Api::Rest::Admin::Routing::AreaPrefixesController < Api::Rest::Admin::BaseController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module RoutingTagIdsScopeable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
|
||
scope :routing_tag_ids_covers, ->(*id) do | ||
where("yeti_ext.tag_compare(routing_tag_ids, ARRAY[#{id.join(',')}])>0") | ||
end | ||
|
||
scope :tagged, ->(value) do | ||
if ActiveRecord::Type::Boolean.new.type_cast_from_user(value) | ||
where("routing_tag_ids <> '{}'") # has tags | ||
else | ||
where("routing_tag_ids = '{}'") # no tags | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Api::Rest::Admin::Routing::AreaPrefixResource < ::BaseResource | ||
model_name 'Routing::AreaPrefix' | ||
|
||
attributes :prefix | ||
|
||
has_one :area, class_name: 'Area' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
class FixSharedGw < ActiveRecord::Migration | ||
def up | ||
execute %q{ | ||
CREATE OR REPLACE FUNCTION switch15.process_dp(i_profile switch15.callprofile58_ty, i_destination class4.destinations, i_dp class4.dialpeers, i_customer_acc billing.accounts, i_customer_gw class4.gateways, i_vendor_acc billing.accounts, i_pop_id integer, i_send_billing_information boolean, i_max_call_length integer) RETURNS SETOF switch15.callprofile58_ty | ||
LANGUAGE plpgsql STABLE SECURITY DEFINER COST 10000 | ||
AS $$ | ||
DECLARE | ||
/*dbg{*/ | ||
v_start timestamp; | ||
v_end timestamp; | ||
/*}dbg*/ | ||
v_gw class4.gateways%rowtype; | ||
BEGIN | ||
/*dbg{*/ | ||
v_start:=now(); | ||
--RAISE NOTICE 'process_dp in: %',i_profile;5 | ||
v_end:=clock_timestamp(); | ||
RAISE NOTICE '% ms -> process-DP. Found dialpeer: %',EXTRACT(MILLISECOND from v_end-v_start),row_to_json(i_dp,true); | ||
/*}dbg*/ | ||
--RAISE NOTICE 'process_dp dst: %',i_destination; | ||
if i_dp.gateway_id is null then | ||
PERFORM id from class4.gateway_groups where id=i_dp.gateway_group_id and prefer_same_pop; | ||
IF FOUND THEN | ||
/*rel{*/ | ||
FOr v_gw in select * from class4.gateways cg where cg.gateway_group_id=i_dp.gateway_group_id and cg.contractor_id=i_dp.vendor_id and cg.enabled ORDER BY cg.pop_id=i_pop_id desc,cg.priority desc, random() LOOP | ||
return query select * from process_gw_release(i_profile, i_destination, i_dp, i_customer_acc, | ||
i_customer_gw, i_vendor_acc , v_gw, i_send_billing_information,i_max_call_length); | ||
end loop; | ||
/*}rel*/ | ||
/*dbg{*/ | ||
FOr v_gw in select * from class4.gateways cg where cg.gateway_group_id=i_dp.gateway_group_id AND cg.enabled ORDER BY cg.pop_id=i_pop_id desc,cg.priority desc, random() LOOP | ||
IF v_gw.contractor_id!=i_dp.vendor_id THEN | ||
RAISE WARNING 'process_dp: Gateway owner !=dialpeer owner. Skip gateway'; | ||
continue; | ||
end if; | ||
return query select * from process_gw_debug(i_profile, i_destination, i_dp, i_customer_acc, | ||
i_customer_gw, i_vendor_acc , v_gw, i_send_billing_information,i_max_call_length); | ||
end loop; | ||
/*}dbg*/ | ||
else | ||
/*rel{*/ | ||
FOr v_gw in select * from class4.gateways cg where cg.gateway_group_id=i_dp.gateway_group_id and cg.contractor_id=i_dp.vendor_id AND cg.enabled ORDER BY cg.priority desc, random() LOOP | ||
return query select * from process_gw_release(i_profile, i_destination, i_dp, i_customer_acc, | ||
i_customer_gw, i_vendor_acc , v_gw, i_send_billing_information,i_max_call_length); | ||
end loop; | ||
/*}rel*/ | ||
/*dbg{*/ | ||
FOr v_gw in select * from class4.gateways cg where cg.gateway_group_id=i_dp.gateway_group_id and cg.enabled ORDER BY cg.priority desc, random() LOOP | ||
IF v_gw.contractor_id!=i_dp.vendor_id AND NOT v_gw.is_shared THEN | ||
RAISE WARNING 'process_dp: Gateway owner !=dialpeer owner. Skip gateway'; | ||
continue; | ||
end if; | ||
return query select * from process_gw_debug(i_profile, i_destination, i_dp, i_customer_acc, | ||
i_customer_gw, i_vendor_acc , v_gw, i_send_billing_information,i_max_call_length); | ||
end loop; | ||
/*}dbg*/ | ||
end if; | ||
else | ||
select into v_gw * from class4.gateways cg where cg.id=i_dp.gateway_id and cg.enabled; | ||
if FOUND THEN | ||
IF v_gw.contractor_id!=i_dp.vendor_id AND NOT v_gw.is_shared THEN | ||
RAISE WARNING 'process_dp: Gateway owner !=dialpeer owner. Stop processing'; | ||
return; | ||
end if; | ||
/*rel{*/ | ||
return query select * from | ||
process_gw_release(i_profile, i_destination, i_dp, i_customer_acc,i_customer_gw, i_vendor_acc, v_gw, i_send_billing_information,i_max_call_length); | ||
/*}rel*/ | ||
/*dbg{*/ | ||
return query select * from | ||
process_gw_debug(i_profile, i_destination, i_dp, i_customer_acc,i_customer_gw, i_vendor_acc, v_gw, i_send_billing_information,i_max_call_length); | ||
/*}dbg*/ | ||
else | ||
return; | ||
end if; | ||
end if; | ||
END; | ||
$$; | ||
set search_path TO switch15; | ||
SELECT * from switch15.preprocess_all(); | ||
set search_path TO gui, public, switch, billing, class4, runtime_stats, sys, logs, data_import; | ||
} | ||
end | ||
|
||
def down | ||
execute %q{ | ||
CREATE OR REPLACE FUNCTION switch15.process_dp(i_profile switch15.callprofile58_ty, i_destination class4.destinations, i_dp class4.dialpeers, i_customer_acc billing.accounts, i_customer_gw class4.gateways, i_vendor_acc billing.accounts, i_pop_id integer, i_send_billing_information boolean, i_max_call_length integer) RETURNS SETOF switch15.callprofile58_ty | ||
LANGUAGE plpgsql STABLE SECURITY DEFINER COST 10000 | ||
AS $$ | ||
DECLARE | ||
/*dbg{*/ | ||
v_start timestamp; | ||
v_end timestamp; | ||
/*}dbg*/ | ||
v_gw class4.gateways%rowtype; | ||
BEGIN | ||
/*dbg{*/ | ||
v_start:=now(); | ||
--RAISE NOTICE 'process_dp in: %',i_profile;5 | ||
v_end:=clock_timestamp(); | ||
RAISE NOTICE '% ms -> process-DP. Found dialpeer: %',EXTRACT(MILLISECOND from v_end-v_start),row_to_json(i_dp,true); | ||
/*}dbg*/ | ||
--RAISE NOTICE 'process_dp dst: %',i_destination; | ||
if i_dp.gateway_id is null then | ||
PERFORM id from class4.gateway_groups where id=i_dp.gateway_group_id and prefer_same_pop; | ||
IF FOUND THEN | ||
/*rel{*/ | ||
FOr v_gw in select * from class4.gateways cg where cg.gateway_group_id=i_dp.gateway_group_id and cg.contractor_id=i_dp.vendor_id and cg.enabled ORDER BY cg.pop_id=i_pop_id desc,cg.priority desc, random() LOOP | ||
return query select * from process_gw_release(i_profile, i_destination, i_dp, i_customer_acc, | ||
i_customer_gw, i_vendor_acc , v_gw, i_send_billing_information,i_max_call_length); | ||
end loop; | ||
/*}rel*/ | ||
/*dbg{*/ | ||
FOr v_gw in select * from class4.gateways cg where cg.gateway_group_id=i_dp.gateway_group_id AND cg.enabled ORDER BY cg.pop_id=i_pop_id desc,cg.priority desc, random() LOOP | ||
IF v_gw.contractor_id!=i_dp.vendor_id THEN | ||
RAISE WARNING 'process_dp: Gateway owner !=dialpeer owner. Skip gateway'; | ||
continue; | ||
end if; | ||
return query select * from process_gw_debug(i_profile, i_destination, i_dp, i_customer_acc, | ||
i_customer_gw, i_vendor_acc , v_gw, i_send_billing_information,i_max_call_length); | ||
end loop; | ||
/*}dbg*/ | ||
else | ||
/*rel{*/ | ||
FOr v_gw in select * from class4.gateways cg where cg.gateway_group_id=i_dp.gateway_group_id and cg.contractor_id=i_dp.vendor_id AND cg.enabled ORDER BY cg.priority desc, random() LOOP | ||
return query select * from process_gw_release(i_profile, i_destination, i_dp, i_customer_acc, | ||
i_customer_gw, i_vendor_acc , v_gw, i_send_billing_information,i_max_call_length); | ||
end loop; | ||
/*}rel*/ | ||
/*dbg{*/ | ||
FOr v_gw in select * from class4.gateways cg where cg.gateway_group_id=i_dp.gateway_group_id and cg.enabled ORDER BY cg.priority desc, random() LOOP | ||
IF v_gw.contractor_id!=i_dp.vendor_id THEN | ||
RAISE WARNING 'process_dp: Gateway owner !=dialpeer owner. Skip gateway'; | ||
continue; | ||
end if; | ||
return query select * from process_gw_debug(i_profile, i_destination, i_dp, i_customer_acc, | ||
i_customer_gw, i_vendor_acc , v_gw, i_send_billing_information,i_max_call_length); | ||
end loop; | ||
/*}dbg*/ | ||
end if; | ||
else | ||
select into v_gw * from class4.gateways cg where cg.id=i_dp.gateway_id and cg.enabled; | ||
if FOUND THEN | ||
IF v_gw.contractor_id!=i_dp.vendor_id THEN | ||
RAISE WARNING 'process_dp: Gateway owner !=dialpeer owner. Stop processing'; | ||
return; | ||
end if; | ||
/*rel{*/ | ||
return query select * from | ||
process_gw_release(i_profile, i_destination, i_dp, i_customer_acc,i_customer_gw, i_vendor_acc, v_gw, i_send_billing_information,i_max_call_length); | ||
/*}rel*/ | ||
/*dbg{*/ | ||
return query select * from | ||
process_gw_debug(i_profile, i_destination, i_dp, i_customer_acc,i_customer_gw, i_vendor_acc, v_gw, i_send_billing_information,i_max_call_length); | ||
/*}dbg*/ | ||
else | ||
return; | ||
end if; | ||
end if; | ||
END; | ||
$$; | ||
set search_path TO switch15; | ||
SELECT * from switch15.preprocess_all(); | ||
set search_path TO gui, public, switch, billing, class4, runtime_stats, sys, logs, data_import; | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.