PCqiandao
jingquan huang 5 years ago
commit 8bfd3bfa98

@ -114,11 +114,12 @@ class CoursesController < ApplicationController
#sql = "left join videos on videos.id=course_videos.video_id AND (videos.transcoded=1 OR videos.user_id = #{current_user.id})"
#@videos = paginate videos.joins(sql).includes(video: [user: :user_extension], user: :user_extension)
videos = videos.includes(video: [user: :user_extension],user: :user_extension).select("course_videos.id, course_videos.title, course_videos.link, course_videos.user_id")
videos = videos.joins(:video).select("course_videos.id, course_videos.title, course_videos.link, course_videos.is_link,course_videos.user_id, course_videos.video_id")
videos = videos.where(videos: {transcoded: true})
.or(videos.where(videos: {user_id: current_user.id}))
.or(videos.where(course_videos: {is_link: true}))
@count = videos.count
.or(videos.where(course_videos: {is_link: true})).includes(video: [user: :user_extension], user: :user_extension)
@count = videos.count("course_videos.id")
logger.info("#######count:#{@count}")
@videos = paginate videos
end

@ -1,8 +1,8 @@
class AddTotalDurationToWatchCourseDuration < ActiveRecord::Migration[5.2]
def change
add_column :watch_course_videos, :total_duration, :float, default: 0
WatchVideoHistory.where("created_at < '2020-03-14 00:00:00'").each do |d|
d.watch_course_video.increment!(:total_duration, d.total_duration) if d.watch_course_video.present?
end
#add_column :watch_course_videos, :total_duration, :float, default: 0
#WatchVideoHistory.where("created_at < '2020-03-14 00:00:00'").each do |d|
# d.watch_course_video.increment!(:total_duration, d.total_duration) if d.watch_course_video.present?
#end
end
end

@ -3,17 +3,18 @@ namespace :video_transcode do
desc "视频转码成h264"
task :submit => :environment do
i = []
Video.where.not(uuid: nil, file_url: nil).where(transcoded: false, status: "published").find_each do |v|
Video.where.not(uuid: nil, file_url: nil).where(transcoded: false).find_each do |v|
code_info = AliyunVod::Service.get_meta_code_info(v.uuid)
if v.file_url.include?('.mp4') && code_info[:codecnamne]&.include?("h264")
v.update(transcoded: true)
else
puts("uuid: #{v.uuid}")
i << "#{v.id}, #{v.file_url}, #{code_info[:codecnamne]}"
AliyunVod::Service.submit_transcode_job(v.uuid, 'a0277c5c0c7458458e171b0cee6ebf5e')
AliyunVod::Service.submit_transcode_job(v.uuid, 'a0277c5c0c7458458e171b0cee6ebf5e') rescue nil
end
end
puts "###########转码个数:#{i.size}"
puts "###########id,file_url, codecnamne:#{i}"
Video.where(transcoded: false).update_all(transcoded: true)
end
end
Loading…
Cancel
Save