Class: Conversant::V3::Services::LMS::Dashboard
- Inherits:
-
Object
- Object
- Conversant::V3::Services::LMS::Dashboard
- Defined in:
- sig/conversant/v3/services/lms.rbs,
lib/conversant/v3/services/lms/dashboard.rb
Overview
Dashboard metrics for LMS
Instance Attribute Summary collapse
- #parent ⇒ LMS readonly
Instance Method Summary collapse
- #dvr ⇒ Hash[String, untyped]?
-
#initialize(parent) ⇒ Dashboard
constructor
A new instance of Dashboard.
- #live ⇒ Hash[String, untyped]?
- #logger ⇒ Object
- #parse_timestamp(timestamp_text) ⇒ Time?
- #recent_jobs ⇒ Array[Hash[Symbol, untyped]]
- #vod ⇒ Hash[String, untyped]?
Constructor Details
#initialize(parent) ⇒ Dashboard
Returns a new instance of Dashboard.
10 11 12 |
# File 'lib/conversant/v3/services/lms/dashboard.rb', line 10 def initialize(parent) @parent = parent end |
Instance Attribute Details
#parent ⇒ LMS (readonly)
8 9 10 |
# File 'lib/conversant/v3/services/lms/dashboard.rb', line 8 def parent @parent end |
Instance Method Details
#dvr ⇒ Hash[String, untyped]?
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/conversant/v3/services/lms/dashboard.rb', line 36 def dvr payload = { _: (Time.now.to_f * 1000).to_i } response = @parent.send(:call, 'GET', "/v4/dvr/duration?#{payload.to_query}") return nil if response.nil? JSON.parse(response) rescue StandardError => e logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#live ⇒ Hash[String, untyped]?
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/conversant/v3/services/lms/dashboard.rb', line 14 def live payload = { _: (Time.now.to_f * 1000).to_i } response = @parent.send(:call, 'GET', "/v4/live/duration?#{payload.to_query}") return nil if response.nil? JSON.parse(response) rescue StandardError => e logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |
#logger ⇒ Object
90 91 92 |
# File 'lib/conversant/v3/services/lms/dashboard.rb', line 90 def logger @parent.send(:logger) end |
#parse_timestamp(timestamp_text) ⇒ Time?
82 83 84 85 86 87 88 |
# File 'lib/conversant/v3/services/lms/dashboard.rb', line 82 def () return nil unless Time.at(.to_i / 1000) rescue StandardError nil end |
#recent_jobs ⇒ Array[Hash[Symbol, untyped]]
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 73 74 75 76 77 78 |
# File 'lib/conversant/v3/services/lms/dashboard.rb', line 47 def recent_jobs response = @parent.send(:call, 'GET', '/dashboard/dashboard') return [] if response.nil? # Parse HTML response to extract job data require 'nokogiri' if defined?(Nokogiri) return [] unless defined?(Nokogiri) doc = Nokogiri::HTML.parse(response) table = doc.at('table') return [] if table.nil? table.search('tr').map do |row| cells = row.search('td') next [] if cells.empty? app_name, stream_name, type, created, started, recording, status = cells { app_name: app_name&.text&.strip, stream_name: stream_name&.text&.strip, type: type&.text&.strip, created: (created&.text), started: (started&.text), recording: recording&.text&.strip, status: status&.text&.strip } end.flatten.compact rescue StandardError => e logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" [] end |
#vod ⇒ Hash[String, untyped]?
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/conversant/v3/services/lms/dashboard.rb', line 25 def vod payload = { _: (Time.now.to_f * 1000).to_i } response = @parent.send(:call, 'GET', "/v4/live/duration?#{payload.to_query}") return nil if response.nil? JSON.parse(response) rescue StandardError => e logger.error "#{@parent.send(:identifier)}.METHOD:#{__method__}.EXCEPTION:#{e.}" nil end |