Class: Conversant::V3::Services::VMS::Business
- Inherits:
-
Object
- Object
- Conversant::V3::Services::VMS::Business
- Defined in:
- lib/conversant/v3/services/vms/business.rb
Overview
Business metrics service for VMS
Provides business-level metrics for billing and reporting including duration, volume, and transcoding statistics broken down by resolution (SD, HD, UHD) and operation type.
Instance Attribute Summary collapse
-
#parent ⇒ VMS
readonly
The parent VMS service instance.
Instance Method Summary collapse
-
#duration(payload) ⇒ Array
Get video duration metrics for billing.
-
#initialize(parent) ⇒ Business
constructor
Initialize business metrics service.
-
#transcoding(payload) ⇒ Hash
Get comprehensive transcoding metrics breakdown.
-
#volume(payload) ⇒ Array
Get video volume metrics for billing.
Constructor Details
#initialize(parent) ⇒ Business
Initialize business metrics service
37 38 39 |
# File 'lib/conversant/v3/services/vms/business.rb', line 37 def initialize(parent) @parent = parent end |
Instance Attribute Details
#parent ⇒ VMS (readonly)
Returns the parent VMS service instance.
32 33 34 |
# File 'lib/conversant/v3/services/vms/business.rb', line 32 def parent @parent end |
Instance Method Details
#duration(payload) ⇒ Array
Get video duration metrics for billing
Retrieves video transcoding duration metrics aggregated by month for billing and usage reporting purposes.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/conversant/v3/services/vms/business.rb', line 57 def duration(payload) month = extract_month(payload) search_payload = { month: month, selectType: 'vtd', customerType: @parent.type || 2, _: (Time.now.to_f * 1000).to_i.to_s } response = @parent.send(:call, 'GET', "/v5/reporting/vms/business/usage/search?#{search_payload.to_query}") return [] if response.nil? JSON.parse(response) rescue StandardError => e logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" [] end |
#transcoding(payload) ⇒ Hash
Get comprehensive transcoding metrics breakdown
Retrieves detailed transcoding metrics broken down by resolution (SD, HD, UHD) and operation type (transcoding vs transmuxing). Useful for detailed billing and capacity analysis.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/conversant/v3/services/vms/business.rb', line 136 def transcoding(payload) report_vms = { vms_transcoding: 0, vms_transmuxing: 0, vms_transcoding_sd: 0, vms_transcoding_hd: 0, vms_transcoding_uhd: 0 } vms_trans = duration(payload)&.first return report_vms unless vms_trans name = vms_trans.keys&.first if vms_trans[name].present? && !vms_trans[name].empty? vms_trans[name]&.each do |item| report_vms[:vms_transmuxing] += item['transmux']&.to_f || 0 report_vms[:vms_transcoding_sd] += (item['h264SdTranscoding']&.to_f || 0) + (item['h265SdTranscoding']&.to_f || 0) report_vms[:vms_transcoding_hd] += (item['h264HdTranscoding']&.to_f || 0) + (item['h265HdTranscoding']&.to_f || 0) report_vms[:vms_transcoding_uhd] += (item['h264UhdTranscoding']&.to_f || 0) + (item['h265UhdTranscoding']&.to_f || 0) end end report_vms[:vms_transcoding] = report_vms[:vms_transcoding_sd] + report_vms[:vms_transcoding_hd] + report_vms[:vms_transcoding_uhd] report_vms rescue StandardError => e logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" report_vms end |
#volume(payload) ⇒ Array
Get video volume metrics for billing
Retrieves video transcoding volume metrics aggregated by month for storage billing and capacity planning.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/conversant/v3/services/vms/business.rb', line 91 def volume(payload) month = extract_month(payload) search_payload = { month: month, selectType: 'vtv', customerType: @parent.type || 2, _: (Time.now.to_f * 1000).to_i.to_s } response = @parent.send(:call, 'GET', "/v5/reporting/vms/business/usage/search?#{search_payload.to_query}") return [] if response.nil? JSON.parse(response) rescue StandardError => e logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" [] end |