视频增加播放时长和次数统计

dev_video
cxt 5 years ago
parent 61cf664f6d
commit d889ff7877

@ -37,4 +37,18 @@ module AliyunVod::Service::VideoManage
result result
end end
# 视频播放数据
def video_data(video_id, start_time, end_time)
params = {
Action: 'DescribePlayVideoStatis',
VideoId: video_id,
StartTime: start_time,
EndTime: end_time
}.merge(base_params)
result = request(:post, params)
result
end
end end

@ -33,4 +33,8 @@ class Video < ApplicationRecord
transitions from: :uploading, to: :uploaded transitions from: :uploading, to: :uploaded
end end
end end
def video_play_duration
(play_duration / (60*60.0)).ceil
end
end end

@ -1,5 +1,6 @@
json.extract! video, :id, :title, :cover_url, :file_url json.extract! video, :id, :title, :cover_url, :file_url, :vv
json.play_duration video.video_play_duration
json.published_at video.display_published_at json.published_at video.display_published_at
json.created_at video.display_created_at json.created_at video.display_created_at
json.updated_at video.display_updated_at json.updated_at video.display_updated_at

@ -0,0 +1,6 @@
class AddNewColumnToVideos < ActiveRecord::Migration[5.2]
def change
add_column :videos, :vv, :integer, default: 0
add_column :videos, :play_duration, :integer, default: 0
end
end

@ -0,0 +1,14 @@
namespace :video do
desc "get video play data"
task :data => :environment do
start_time = [Time.utc(2019,8,19,0,0,0), Time.utc(2019,11,10,0,0,0)]
end_time = [Time.utc(2019,11,09,23,59,59), Time.utc(2020,2,6,23,59,59)]
Video.all.each do |video|
vv = 0
play_duration = 0
end
end
end
Loading…
Cancel
Save