Skip to content

Commit

Permalink
Merge pull request #1120 from senid231/1116-asynchronous-cdr-reports
Browse files Browse the repository at this point in the history
make all CDR reports asynchronous
  • Loading branch information
dmitry-sinina authored Mar 18, 2022
2 parents d76d632 + f8307e9 commit 1eba103
Show file tree
Hide file tree
Showing 70 changed files with 2,532 additions and 777 deletions.
12 changes: 10 additions & 2 deletions app/admin/reports/custom_cdr_schedulers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,20 @@ def scoped_collection
end

form do |f|
f.semantic_errors *f.object.errors.attribute_names
f.inputs do
f.input :period
f.contractor_input :customer_id, label: 'Customer', path_params: { q: { customer_eq: true } }
f.input :filter
f.input :group_by, as: :select, input_html: { class: 'chosen-sortable', multiple: true }, collection: Report::CustomData::CDR_COLUMNS.map { |a| [a, a] }
f.input :send_to, as: :select, input_html: { class: 'chosen-sortable', multiple: true }, collection: Billing::Contact.collection, hint: f.object.send_to_hint
f.input :group_by,
as: :select,
input_html: { class: 'chosen-sortable', multiple: true },
collection: Report::CustomCdr::CDR_COLUMNS.map { |a| [a, a] }
f.input :send_to,
as: :select,
input_html: { class: 'chosen-sortable', multiple: true },
collection: Billing::Contact.collection,
hint: f.object.send_to_hint
end
f.actions
end
Expand Down
51 changes: 32 additions & 19 deletions app/admin/reports/custom_cdrs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@
config.batch_actions = true
actions :index, :destroy, :create, :new

permit_params :date_start,
:date_end,
:customer_id,
:filter,
send_to: [],
group_by: []

controller do
def build_new_resource
CustomCdrReportForm.new(*resource_params)
Report::CustomCdrForm.new(*resource_params)
end

def scoped_collection
Expand All @@ -28,6 +21,13 @@ def create

report_scheduler Report::CustomCdrScheduler

filter :id
boolean_filter :completed
filter :date_start, as: :date_time_range
filter :date_end, as: :date_time_range
filter :created_at, as: :date_time_range
contractor_filter :customer_id_eq, label: 'Customer', path_params: { q: { customer_eq: true } }

index do
selectable_column
id_column
Expand All @@ -43,17 +43,37 @@ def create
column :group_by
end

permit_params :date_start,
:date_end,
:customer_id,
:filter,
send_to: [],
group_by: []

form do |f|
f.semantic_errors *f.object.errors.attribute_names
f.inputs do
f.input :date_start, as: :date_time_picker, wrapper_html: { class: 'datetime_preset_pair', data: { show_time: 'true' } }
f.input :date_end, as: :date_time_picker
f.contractor_input :customer_id, label: 'Customer', path_params: { q: { customer_eq: true } }
f.input :date_start,
as: :date_time_picker,
wrapper_html: {
class: 'datetime_preset_pair',
data: { show_time: 'true' }
}

f.input :date_end,
as: :date_time_picker

f.contractor_input :customer_id,
label: 'Customer',
path_params: { q: { customer_eq: true } }

f.input :filter

f.input :group_by,
as: :select,
input_html: { class: 'chosen-sortable', multiple: true },
collection: Report::CustomData::CDR_COLUMNS
collection: Report::CustomCdr::CDR_COLUMNS

f.input :send_to,
as: :select,
input_html: { class: 'chosen-sortable', multiple: true },
Expand All @@ -62,11 +82,4 @@ def create
end
f.actions
end

filter :id
boolean_filter :completed
filter :date_start, as: :date_time_range
filter :date_end, as: :date_time_range
filter :created_at, as: :date_time_range
contractor_filter :customer_id_eq, label: 'Customer', path_params: { q: { customer_eq: true } }
end
11 changes: 7 additions & 4 deletions app/admin/reports/custom_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
end

action_item :reports, only: :index do
link_to 'Delete report', custom_cdr_path(assigns[:custom_cdr].id), method: :delete,
data: { confirm: I18n.t('active_admin.delete_confirmation') }, class: 'member_link delete_link'
link_to 'Delete report',
custom_cdr_path(assigns[:custom_cdr].id),
method: :delete,
data: { confirm: I18n.t('active_admin.delete_confirmation') },
class: 'member_link delete_link'
end

sidebar 'Custom CDR Report', class: 'toggle', priority: 0 do
Expand All @@ -32,15 +35,15 @@
row :filter
row :group_by do
content_tag :ul do
assigns[:custom_cdr].group_by_arr.collect { |item| concat(content_tag(:li, item)) }
assigns[:custom_cdr].group_by.collect { |item| concat(content_tag(:li, item)) }
end
end
row :created_at
end
end
end

assoc_filter_columns = Report::CustomData::CDR_COLUMNS - %i[destination_id dialpeer_id customer_id vendor_id vendor_acc_id customer_acc_id]
assoc_filter_columns = Report::CustomCdr::CDR_COLUMNS - %i[destination_id dialpeer_id customer_id vendor_id vendor_acc_id customer_acc_id]
assoc_filter_columns.each do |key|
filter key.to_s[0..-4].to_sym,
if: proc { @custom_cdr.group_by_include? key },
Expand Down
3 changes: 2 additions & 1 deletion app/admin/reports/customer_traffic_data_by_destinations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def scoped_collection
div class: :report_sidebar_info do
attributes_table_for assigns[:customer_traffic] do
row :id
row :date_startff
row :completed
row :date_start
row :date_end
row :customer
row :created_at
Expand Down
1 change: 1 addition & 0 deletions app/admin/reports/customer_traffic_data_by_vendors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def scoped_collection
div class: :report_sidebar_info do
attributes_table_for assigns[:customer_traffic] do
row :id
row :completed
row :date_start
row :date_end
row :customer
Expand Down
1 change: 1 addition & 0 deletions app/admin/reports/customer_traffic_data_fulls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def scoped_collection
div class: :report_sidebar_info do
attributes_table_for assigns[:customer_traffic] do
row :id
row :completed
row :date_start
row :date_end
row :customer
Expand Down
1 change: 1 addition & 0 deletions app/admin/reports/customer_traffic_schedulers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def scoped_collection
end

form do |f|
f.semantic_errors *f.object.errors.attribute_names
f.inputs do
f.input :period
f.contractor_input :customer_id, label: 'Customer', path_params: { q: { customer_eq: true } }
Expand Down
53 changes: 40 additions & 13 deletions app/admin/reports/customer_traffics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,28 @@
config.batch_actions = true
actions :index, :destroy, :create, :new

permit_params :date_start, :date_end,
:customer_id, group_by: [], send_to: []

controller do
def build_new_resource
Report::CustomerTrafficForm.new(*resource_params)
end

def scoped_collection
super.preload(:customer)
end
end

report_scheduler Report::CustomerTrafficScheduler

filter :id
boolean_filter :completed
filter :date_start, as: :date_time_range
filter :date_end, as: :date_time_range
filter :created_at, as: :date_time_range

contractor_filter :customer_id_eq,
label: 'Customer',
path_params: { q: { customer_eq: true } }

index do
selectable_column
id_column
Expand All @@ -24,25 +35,41 @@ def scoped_collection
link_to('By destinations', customer_traffic_customer_traffic_data_by_destinations_path(row), class: :member_link) +
link_to('By vendors and destinations', customer_traffic_customer_traffic_data_fulls_path(row))
end
column :completed
column :created_at
column :customer
column :date_start
column :date_end
end

permit_params :date_start,
:date_end,
:customer_id,
send_to: []

form do |f|
f.semantic_errors *f.object.errors.attribute_names
f.inputs do
f.input :date_start, as: :date_time_picker, wrapper_html: { class: 'datetime_preset_pair', data: { show_time: 'true' } }
f.input :date_end, as: :date_time_picker
f.contractor_input :customer_id, label: 'Customer', path_params: { q: { customer_eq: true } }
f.input :send_to, as: :select, input_html: { class: 'chosen', multiple: true }, collection: Billing::Contact.collection, hint: f.object.send_to_hint
f.input :date_start,
as: :date_time_picker,
wrapper_html: {
class: 'datetime_preset_pair',
data: { show_time: 'true' }
}

f.input :date_end,
as: :date_time_picker

f.contractor_input :customer_id,
label: 'Customer',
path_params: { q: { customer_eq: true } }

f.input :send_to,
as: :select,
input_html: { class: 'chosen', multiple: true },
collection: Billing::Contact.collection,
hint: f.object.send_to_hint
end
f.actions
end

filter :id
filter :date_start, as: :date_time_range
filter :date_end, as: :date_time_range
filter :created_at, as: :date_time_range
contractor_filter :customer_id_eq, label: 'Customer', path_params: { q: { customer_eq: true } }
end
26 changes: 22 additions & 4 deletions app/admin/reports/interval_cdr_schedulers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,32 @@
end

form do |f|
f.semantic_errors *f.object.errors.attribute_names
f.inputs do
f.input :period
f.input :interval_length, as: :select, collection: [['5 Min', 5], ['10 Min', 10], ['30 Min', 30], ['1 Hour', 60], ['6 Hours', 360], ['1 Day', 1440]]
f.input :interval_length,
as: :select,
collection: Report::IntervalCdr::INTERVALS.map { |num, name| [name, num] }

f.input :aggregation_function
f.input :aggregate_by, as: :select, input_html: { class: 'chosen' }, collection: Report::IntervalCdr::CDR_AGG_COLUMNS

f.input :aggregate_by,
as: :select,
input_html: { class: 'chosen' },
collection: Report::IntervalCdr::CDR_AGG_COLUMNS

f.input :filter
f.input :group_by, as: :select, input_html: { class: 'chosen', multiple: true }, collection: Report::IntervalCdr::CDR_COLUMNS
f.input :send_to, as: :select, input_html: { class: 'chosen', multiple: true }, collection: Billing::Contact.collection, hint: f.object.send_to_hint

f.input :group_by,
as: :select,
input_html: { class: 'chosen', multiple: true },
collection: Report::IntervalCdr::CDR_COLUMNS

f.input :send_to,
as: :select,
input_html: { class: 'chosen', multiple: true },
collection: Billing::Contact.collection,
hint: f.object.send_to_hint
end
f.actions
end
Expand Down
Loading

0 comments on commit 1eba103

Please sign in to comment.