Class: Conversant::V3::Services::VMS::Partner::Business

Inherits:
Object
  • Object
show all
Defined in:
lib/conversant/v3/services/vms/partner/business.rb

Overview

VMS Business analytics for partner-level business reporting

Provides business-focused analytics methods that aggregate transcoding data for VOD (Video on Demand) billing and capacity planning.

Since:

  • 1.0.16

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Business

Initialize partner VMS business service

Parameters:

Since:

  • 1.0.16



21
22
23
# File 'lib/conversant/v3/services/vms/partner/business.rb', line 21

def initialize(parent)
  @parent = parent
end

Instance Attribute Details

#parentConversant::V3::Services::VMS::Partner::Analytics (readonly)

Returns the parent analytics instance.

Returns:

Since:

  • 1.0.16



16
17
18
# File 'lib/conversant/v3/services/vms/partner/business.rb', line 16

def parent
  @parent
end

Instance Method Details

#transcoding(**args) ⇒ Hash

Fetches transcoding business analytics with codec breakdown

Aggregates VOD transcoding data including transmuxing and transcoding across different resolutions (SD, HD, UHD) and codecs (H264, H265).

Examples:

Get VOD transcoding business metrics

vms = Conversant::V3.vms(12345)
business = vms.partner.analytics.business
metrics = business.transcoding(startTime: Time.now.beginning_of_month)
puts "Total transcoding: #{metrics[:vms_transcoding]} minutes"
puts "SD: #{metrics[:vms_transcoding_sd]}, HD: #{metrics[:vms_transcoding_hd]}, UHD: #{metrics[:vms_transcoding_uhd]}"

Parameters:

  • args (Hash)

    Parameters for the query

Options Hash (**args):

  • :startTime (Time, String)

    start time for the report (defaults to beginning of current month)

  • :type (String, Integer)

    customer type filter (defaults to 2)

Returns:

  • (Hash)

    Transcoding business data with breakdown by codec and resolution. Hash contains:

    • :vms_transcoding [Float] total transcoding duration
    • :vms_transmuxing [Float] transmuxing duration
    • :vms_transcoding_sd [Float] SD transcoding duration
    • :vms_transcoding_hd [Float] HD transcoding duration
    • :vms_transcoding_uhd [Float] UHD transcoding duration

Since:

  • 1.0.16



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/conversant/v3/services/vms/partner/business.rb', line 49

def transcoding(**args)
  transcoding = {
    vms_transcoding: 0,
    vms_transmuxing: 0,
    vms_transcoding_sd: 0,
    vms_transcoding_hd: 0,
    vms_transcoding_uhd: 0
  }

  data = @parent.duration_of_vod(**args).first
  return transcoding if data.nil?

  name = data.keys.first

  if data[name].present?
    data[name].each do |item|
      transcoding[:vms_transmuxing] += item['transmux'].to_f
      transcoding[:vms_transcoding_sd] += item['h264SdTranscoding'].to_f + item['h265SdTranscoding'].to_f
      transcoding[:vms_transcoding_hd] += item['h264HdTranscoding'].to_f + item['h265HdTranscoding'].to_f
      transcoding[:vms_transcoding_uhd] += item['h264UhdTranscoding'].to_f + item['h265UhdTranscoding'].to_f
    end
  end

  transcoding[:vms_transcoding] =
    transcoding[:vms_transcoding_sd] + transcoding[:vms_transcoding_hd] + transcoding[:vms_transcoding_uhd]
  transcoding
rescue StandardError => e
  logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
  transcoding
end