Skip to content

Commit

Permalink
Admin api cdr p charge info (#1665)
Browse files Browse the repository at this point in the history
* admin api: CDR add p_charge_info_in and network types
* admin api: CDR add src/dst_network_type relationships
  • Loading branch information
dmitry-sinina authored Dec 25, 2024
1 parent 07b3cc7 commit 0f5236d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ GEM
pgq_prometheus (0.2.3)
prometheus_exporter
public_suffix (4.0.6)
puma (6.4.3)
puma (6.5.0)
nio4r (~> 2.0)
puma_worker_killer (0.3.1)
get_process_mem (~> 0.2)
Expand Down
6 changes: 6 additions & 0 deletions app/resources/api/rest/admin/cdr_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def self.updatable_fields(_context)
:customer_duration,
:vendor_duration,
:destination_rate_policy_id,
:p_charge_info_in,
:metadata

has_one :rateplan, class_name: 'Rateplan', always_include_linkage_data: true
Expand All @@ -135,8 +136,10 @@ def self.updatable_fields(_context)
has_one :term_gw, class_name: 'Gateway', always_include_linkage_data: true
has_one :dst_country, class_name: 'Country', always_include_linkage_data: true
has_one :dst_network, class_name: 'Network', always_include_linkage_data: true
has_one :dst_network_type, class_name: 'Network', always_include_linkage_data: true
has_one :src_country, class_name: 'Country', always_include_linkage_data: true
has_one :src_network, class_name: 'Network', always_include_linkage_data: true
has_one :src_network_type, class_name: 'Network', always_include_linkage_data: true

filter :customer_auth_external_id_eq, apply: lambda { |records, values, _options|
records.where(customer_auth_external_id: values)
Expand Down Expand Up @@ -237,8 +240,10 @@ def self.updatable_fields(_context)
ransack_filter :term_gw_id, type: :foreign_key
ransack_filter :dst_country_id, type: :foreign_key
ransack_filter :dst_network_id, type: :foreign_key
ransack_filter :dst_network_type_id, type: :foreign_key
ransack_filter :src_country_id, type: :foreign_key
ransack_filter :src_network_id, type: :foreign_key
ransack_filter :src_network_type_id, type: :foreign_key

ransack_filter :id, type: :number
ransack_filter :time_start, type: :datetime
Expand Down Expand Up @@ -346,4 +351,5 @@ def self.updatable_fields(_context)
ransack_filter :vendor_duration, type: :number
ransack_filter :destination_rate_policy_id, type: :number
ransack_filter :audio_recorded, type: :boolean
ransack_filter :p_charge_info_in, type: :string
end
12 changes: 10 additions & 2 deletions spec/controllers/api/rest/admin/cdrs_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@
it_behaves_like :jsonapi_filters_by_number_field, :customer_price_no_vat
it_behaves_like :jsonapi_filters_by_number_field, :customer_duration
it_behaves_like :jsonapi_filters_by_number_field, :vendor_duration
it_behaves_like :jsonapi_filters_by_string_field, :p_charge_info_in
end

describe 'GET show' do
Expand All @@ -556,7 +557,7 @@
}
end
let(:includes) do
%w[rateplan dialpeer pop routing-group destination customer-auth vendor customer vendor-acc customer-acc orig-gw term-gw routing-plan src-country src-network dst-country dst-network]
%w[rateplan dialpeer pop routing-group destination customer-auth vendor customer vendor-acc customer-acc orig-gw term-gw routing-plan src-country src-network src-network-type dst-country dst-network dst-network-type]
end

it 'http status should eq 200' do
Expand Down Expand Up @@ -676,7 +677,8 @@
'customer-duration' => cdr.customer_duration,
'vendor-duration' => cdr.vendor_duration,
'destination-rate-policy-id' => cdr.destination_rate_policy_id,
'metadata' => nil
'metadata' => nil,
'p-charge-info-in' => cdr.p_charge_info_in
},
'relationships' => hash_including(
'rateplan' => hash_including(
Expand Down Expand Up @@ -739,11 +741,17 @@
'src-network' => hash_including(
'data' => nil
),
'src-network-type' => hash_including(
'data' => nil
),
'dst-country' => hash_including(
'data' => nil
),
'dst-network' => hash_including(
'data' => nil
),
'dst-network-type' => hash_including(
'data' => nil
)
)
)
Expand Down

0 comments on commit 0f5236d

Please sign in to comment.