Module: KalturaFu::Report
- Defined in:
- lib/kaltura_fu/report.rb
Overview
The Report module provides class methods to retrieve analytic information and reports from Kaltura entries.
Instance Method Summary collapse
-
#generate_report(from_date, video_list) ⇒ Array
Returns an Array of hashes that contains a Kaltura content drop-off report ordered by # of plays descending.
-
#generate_report_csv_url(from_date, video_list) ⇒ String
creates a report CSV on the kaltura server and then returns the url to grab it.
-
#generate_report_total(from_date, video_list) ⇒ Hash
Returns a grand total of the plays broken down by content drop-off given a list of Kaltura entries.
-
#generate_report_video_count(from_date, video_list) ⇒ Object
Returns the total number of Kaltura entries that had any plays during the reporting period.
Instance Method Details
#generate_report(from_date, video_list) ⇒ Array
Returns an Array of hashes that contains a Kaltura content drop-off report ordered by # of plays descending. Kaltura treats # of plays as a string, so 5 comes before 353.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/kaltura_fu/report.rb', line 19 def generate_report(from_date,video_list) hash_array = [] KalturaFu.check_for_client_session report_filter = Kaltura::Filter::ReportInputFilter.new report_filter.from_date = from_date.to_i report_filter.to_date = Time.now.utc.to_i report_pager = Kaltura::FilterPager.new report_pager.page_size = 1000 report_raw = KalturaFu.client.report_service.get_table(Kaltura::Constants::ReportType::CONTENT_DROPOFF, report_filter, report_pager, Kaltura::Constants::Media::OrderBy::PLAYS_DESC, video_list) unless report_raw.data.nil? report_split_by_entry = report_raw.data.split(";") report_split_by_entry.each do |row| segment = row.split(",") row_hash = {} row_hash[:entry_id] = segment.at(0) row_hash[:plays] = segment.at(2) row_hash[:play_through_25] = segment.at(3) row_hash[:play_through_50] = segment.at(4) row_hash[:play_through_75] = segment.at(5) row_hash[:play_through_100] = segment.at(6) hash_array << row_hash end hash_array = hash_array.sort{|a,b| b[:plays].to_i <=> a[:plays].to_i} end hash_array end |
#generate_report_csv_url(from_date, video_list) ⇒ String
creates a report CSV on the kaltura server and then returns the url to grab it. Unfortunately the MIME type of the resource is “text/plain” instead of “text/csv” so there isn’t a ton you can do with it.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/kaltura_fu/report.rb', line 63 def generate_report_csv_url(from_date,video_list) report_title = "TTV Video Report" report_text = "I'm not sure what this is" headers = "Kaltura Entry,Plays,25% Play-through,50% Play-through, 75% Play-through, 100% Play-through, Play-Through Ratio" KalturaFu.check_for_client_session report_filter = Kaltura::Filter::ReportInputFilter.new report_filter.from_date = from_date.to_i report_filter.to_date = Time.now.utc.to_i report_pager = Kaltura::FilterPager.new report_pager.page_size = 1000 report_url = KalturaFu.client.report_service.get_url_for_report_as_csv(report_title, report_text, headers, Kaltura::Constants::ReportType::CONTENT_DROPOFF, report_filter, "", report_pager, Kaltura::Constants::Media::OrderBy::PLAYS_DESC, video_list) report_url end |
#generate_report_total(from_date, video_list) ⇒ Hash
Returns a grand total of the plays broken down by content drop-off given a list of Kaltura entries.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/kaltura_fu/report.rb', line 96 def generate_report_total(from_date,video_list) row_hash = {} KalturaFu.check_for_client_session report_filter = Kaltura::Filter::ReportInputFilter.new report_filter.from_date = from_date.to_i report_filter.to_date = Time.now.utc.to_i report_raw = KalturaFu.client.report_service.get_total(Kaltura::Constants::ReportType::CONTENT_DROPOFF, report_filter, video_list) unless report_raw.data.nil? segment = report_raw.data.split(",") row_hash[:plays] = segment.at(0) row_hash[:play_through_25] = segment.at(1) row_hash[:play_through_50] = segment.at(2) row_hash[:play_through_75] = segment.at(3) row_hash[:play_through_100] = segment.at(4) row_hash end end |
#generate_report_video_count(from_date, video_list) ⇒ Object
Returns the total number of Kaltura entries that had any plays during the reporting period.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/kaltura_fu/report.rb', line 125 def generate_report_video_count(from_date,video_list) row_hash = {} KalturaFu.check_for_client_session report_filter = Kaltura::Filter::ReportInputFilter.new report_filter.from_date = from_date.to_i report_filter.to_date = Time.now.utc.to_i report_pager = Kaltura::FilterPager.new report_pager.page_size = 1000 report_raw = KalturaFu.client.report_service.get_table(Kaltura::Constants::ReportType::CONTENT_DROPOFF, report_filter, report_pager, Kaltura::Constants::Media::OrderBy::PLAYS_DESC, video_list) unless report_raw.data.nil? report_raw.total_count end end |