Class: Conversant::V3::Services::LMS::Partner::Business

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

Overview

LMS Business analytics for partner-level business reporting

Provides business-focused analytics methods that aggregate transcoding, recording, and streaming data for billing and capacity planning.

Since:

  • 1.0.15

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Business

Initialize partner LMS business service

Parameters:

Since:

  • 1.0.15



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

def initialize(parent)
  @parent = parent
end

Instance Attribute Details

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

Returns the parent analytics instance.

Returns:

Since:

  • 1.0.15



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

def parent
  @parent
end

Instance Method Details

#recording(**args) ⇒ Hash?

Fetches recording business analytics with codec breakdown

Aggregates recording data including total recording duration, transmuxing, audio-only, and transcoding across different resolutions and codecs.

Examples:

Get recording business metrics

business = lms.partner.analytics.business
metrics = business.recording(startTime: Time.now.beginning_of_month)
puts "Total recording: #{metrics[:lms_recording]} minutes"

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, nil)

    Recording business data with breakdown by codec and resolution, or nil if no data

Since:

  • 1.0.15



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/conversant/v3/services/lms/partner/business.rb', line 91

def recording(**args)
  recording = {
    lms_recording: 0,
    lms_transmuxing: 0,
    lms_transcoding_sd: 0,
    lms_transcoding_hd: 0,
    lms_transcoding_uhd: 0,
    lms_audio_only: 0
  }

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

  name = data.keys.first

  data[name]&.each do |item|
    recording[:lms_recording] += item[:total].to_f
    recording[:lms_transmuxing] += item[:transmux].to_f
    recording[:lms_audio_only] += item[:audioOnly].to_f
    recording[:lms_transcoding_sd] += item[:h264SdTranscoding].to_f + item[:h265SdTranscoding].to_f
    recording[:lms_transcoding_hd] += item[:h264HdTranscoding].to_f + item[:h265HdTranscoding].to_f
    recording[:lms_transcoding_uhd] += item[:h264UhdTranscoding].to_f + item[:h265UhdTranscoding].to_f
  end

  recording
rescue StandardError => e
  logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
  nil
end

#stream_jobs(**args) ⇒ Array

Fetches stream jobs data

Retrieves the number of live streaming jobs for business usage reporting. This is an alias for the parent analytics' no_of_live_jobs method.

Examples:

Get stream jobs count

business = lms.partner.analytics.business
jobs = business.stream_jobs(startTime: Time.now.beginning_of_month)

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:

  • (Array)

    Stream jobs count data, or empty array on error

Since:

  • 1.0.15



137
138
139
# File 'lib/conversant/v3/services/lms/partner/business.rb', line 137

def stream_jobs(**args)
  @parent.no_of_live_jobs(**args)
end

#transcoding(**args) ⇒ Hash?

Fetches transcoding business analytics with codec breakdown

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

Examples:

Get transcoding business metrics

business = lms.partner.analytics.business
metrics = business.transcoding(startTime: Time.now.beginning_of_month)
puts "Total transcoding: #{metrics[:lms_transcoding]} minutes"
puts "SD: #{metrics[:lms_transcoding_sd]}, HD: #{metrics[:lms_transcoding_hd]}, UHD: #{metrics[:lms_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, nil)

    Transcoding business data with breakdown by codec and resolution, or nil if no data

Since:

  • 1.0.15



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/conversant/v3/services/lms/partner/business.rb', line 43

def transcoding(**args)
  transcode = {
    lms_transcoding: 0,
    lms_transmuxing: 0,
    lms_transcoding_sd: 0,
    lms_transcoding_hd: 0,
    lms_transcoding_uhd: 0,
    lms_audio_only: 0
  }

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

  name = data.keys.first

  data[name]&.each do |item|
    transcode[:lms_transmuxing] += item[:transmux].to_f
    transcode[:lms_audio_only] += item[:audioOnly].to_f
    transcode[:lms_transcoding_sd] += item[:h264SdTranscoding].to_f + item[:h265SdTranscoding].to_f
    transcode[:lms_transcoding_hd] += item[:h264HdTranscoding].to_f + item[:h265HdTranscoding].to_f
    transcode[:lms_transcoding_uhd] += item[:h264UhdTranscoding].to_f + item[:h265UhdTranscoding].to_f
  end

  transcode[:lms_transcoding] =
    transcode[:lms_transcoding_sd] + transcode[:lms_transcoding_hd] + transcode[:lms_transcoding_uhd]
  transcode
rescue StandardError => e
  logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.message}"
  nil
end