Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_video
杨树林 5 years ago
commit 19d5853b75

@ -39,6 +39,13 @@ class Users::VideosController < Users::BaseController
@videos = paginate videos @videos = paginate videos
end end
def get_video_data
start_time = params[:start_time].to_time.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
end_time = params[:end_time].to_time.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
result = AliyunVod::Service.video_data(current_video.uuid, start_time, end_time)
render :json => {data: result}
end
def batch_publish def batch_publish
Videos::BatchPublishService.call(observed_user, batch_publish_params) Videos::BatchPublishService.call(observed_user, batch_publish_params)
render_ok render_ok

@ -52,7 +52,7 @@ class UsersController < ApplicationController
def attachment_show def attachment_show
file_name = params[:file_name] file_name = params[:file_name]
path = params[:path] path = params[:path] || edu_setting('attachment_folder')
send_file "#{path}/#{file_name}", :filename => "#{file_name}", send_file "#{path}/#{file_name}", :filename => "#{file_name}",
:type => 'game', :type => 'game',
:disposition => 'attachment' #inline can open in browser :disposition => 'attachment' #inline can open in browser

@ -152,7 +152,7 @@ module ShixunsHelper
challenge_program_name = [] challenge_program_name = []
shixun.challenges.map(&:exec_path).each do |exec_path| shixun.challenges.map(&:exec_path).each do |exec_path|
challenge_program_name << "\"#{exec_path}\"" challenge_program_name << "\"#{exec_path}\""
if shixun.main_mirror_name == "Java" if shixun.main_mirror_name == "Java" || shixun.main_mirror_name == "Openjdk10/VNC"
if exec_path.nil? || exec_path.split("src/")[1].nil? if exec_path.nil? || exec_path.split("src/")[1].nil?
source = "\"\"" source = "\"\""
else else

@ -44,7 +44,8 @@ module AliyunVod::Service::VideoManage
Action: 'DescribePlayVideoStatis', Action: 'DescribePlayVideoStatis',
VideoId: video_id, VideoId: video_id,
StartTime: start_time, StartTime: start_time,
EndTime: end_time EndTime: end_time,
Interval: 'day'
}.merge(base_params) }.merge(base_params)
result = request(:post, params) result = request(:post, params)

@ -10,3 +10,4 @@ json.created_on attachment.created_on
json.is_pdf attachment.is_history_pdf? json.is_pdf attachment.is_history_pdf?
json.url attachment.is_history_pdf? ? attachment_path(attachment, type: 'history',disposition:"inline") : attachment_path(attachment, type: 'history') json.url attachment.is_history_pdf? ? attachment_path(attachment, type: 'history',disposition:"inline") : attachment_path(attachment, type: 'history')
json.attachment_id attachment.attachment_id json.attachment_id attachment.attachment_id
json.content_type attachment.content_type

@ -15,3 +15,4 @@ json.created_on attachment.created_on
json.content_type attachment.content_type json.content_type attachment.content_type
json.is_pdf attachment.is_pdf? json.is_pdf attachment.is_pdf?
json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment) json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment)
json.play_url attachment_show_users_path(file_name: local_path(attachment))

@ -4,3 +4,4 @@ json.filesize number_to_human_size(attachment.filesize)
json.is_pdf attachment.is_pdf? json.is_pdf attachment.is_pdf?
json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment) json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment)
json.created_on attachment.created_on json.created_on attachment.created_on
json.content_type attachment.content_type

@ -197,6 +197,9 @@ Rails.application.routes.draw do
post :batch_publish post :batch_publish
post :cancel post :cancel
end end
member do
get :get_video_data
end
end end
resource :video_auths, only: [:create, :update] resource :video_auths, only: [:create, :update]
end end

@ -1,14 +1,45 @@
namespace :video do namespace :video do
desc "get video play data" desc "get video play data"
task :data => :environment do task :data => :environment do
start_time = [Time.utc(2019,8,19,0,0,0), Time.utc(2019,11,10,0,0,0)] start_times = ['2019-08-19 00:00:00', '2019-11-10 00:00:00']
end_time = [Time.utc(2019,11,09,23,59,59), Time.utc(2020,2,6,23,59,59)] end_times = ['2019-11-09 23:59:59', '2020-02-06 00:00:00']
Video.all.each do |video| Video.all.each do |video|
vv = 0 vv = 0
play_duration = 0 play_duration = 0
start_times.each_with_index do |time, index|
start_time = time.to_time.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
end_time = end_times[index].to_time.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
data = AliyunVod::Service.video_data(video.uuid, start_time, end_time)
puts data
if data[:VideoPlayStatisDetails].present?
sum_duration = data[:VideoPlayStatisDetails][:VideoPlayStatisDetail].map(&:PlayDuration).sum
sum_vv = data[:VideoPlayStatisDetails][:VideoPlayStatisDetail].map(&:vv).sum
vv += sum_vv
play_duration += sum_duration
end
end
video.update!(vv: vv, play_duration: play_duration)
puts video.id
end
end
# 执行示例 bundle exec rake video:sample args=2933,'2019-08-19 00:00:00','2019-11-09 23:59:59'
task :sample => :environment do
if ENV['args']
video_id = ENV['args'].split(",")[0]
start_time = ENV['args'].split(",")[1].to_s.to_time.utc.strftime('%Y-%m-%dT%H:%M:%SZ') # 表示参与人数
end_time = ENV['args'].split(",")[2].to_s.to_time.utc.strftime('%Y-%m-%dT%H:%M:%SZ') # 表示通过人数
video=Video.find video_id
data = AliyunVod::Service.video_data(video.uuid, start_time, end_time)
puts data
end end
end end
end end

@ -20,7 +20,7 @@
} }
.videoItem img.cover { .videoItem img.cover {
width: 100%; width: 100%;
border-radius: 6px 6px 0px 0px; border-radius: 12px 12px 0px 0px;
height: 158px; height: 158px;
} }
.nItem.videoItem:hover .mask { .nItem.videoItem:hover .mask {
@ -34,12 +34,12 @@
display: inline-block; display: inline-block;
} }
.nItem .mask { .nItem .mask {
border-radius: 6px 6px 0px 0px; border-radius: 12px 12px 0px 0px;
display: none; display: none;
text-align: center; text-align: center;
position: absolute; position: absolute;
background: #000; background:rgba(0,0,0,0.39);
opacity: 0.5; /*opacity: 0.5;*/
} }
.videoItem .playWrap { .videoItem .playWrap {
display: none; display: none;
@ -49,6 +49,7 @@
position: absolute; position: absolute;
top: 0px; top: 0px;
left: 0px; left: 0px;
cursor: pointer;
} }
.videoItem img.play { .videoItem img.play {
margin-top: 20%; margin-top: 20%;
@ -57,9 +58,9 @@
} }
.videoItem .square-main { .videoItem .square-main {
padding: 9px 8px; padding: 9px 8px;
background: #fff; background: #fff;
border-radius: 0px 0px 6px 6px; border-radius:12px;
} }
.videoItem .square-main .title{ .videoItem .square-main .title{
max-width: 256px; max-width: 256px;
@ -71,7 +72,11 @@
background: #EAEAEA; background: #EAEAEA;
} }
.videoItem .time { .videoItem .time {
color: #A0A0A0; color: #C0C4CC;
}
.videoItem .square-main .buttonRow .dianjilianicon{
color: #606266 !important;
font-size: 14px !important;
} }
.videoItem .square-main .buttonRow { .videoItem .square-main .buttonRow {
@ -80,8 +85,8 @@
} }
.nItem.videoItem:hover .square-main { .nItem.videoItem:hover .square-main {
color: #fff; /*color: #fff;*/
background: #333; background: #fff;
} }
/* 预览弹框 */ /* 预览弹框 */
@ -117,4 +122,24 @@
.infoVideo .toUploadBtn { .infoVideo .toUploadBtn {
height: 48px; height: 48px;
margin-right: 20px; margin-right: 20px;
}
.play_duration{
width: 100%;
height:30px;
background:rgba(0,0,0,0.39);
/*opacity:0.39;*/
color:#fff;
font-size:12px;
line-height:30px;
text-align: right;
padding-right: 10px;
}
.mp23{
margin-bottom: 23px;
}
.videoItem:hover{
box-shadow:0px 4px 10px 0px rgba(3,7,45,0.1);
border-radius:12px;
} }

@ -20,13 +20,13 @@ const clipboardMap = {}
function VideoInReviewItem (props) { function VideoInReviewItem (props) {
const theme = useContext(ThemeContext); const theme = useContext(ThemeContext);
const { history, file_url, cover_url, title, created_at, published_at, isReview, id const { history, file_url, cover_url, title, created_at, published_at, isReview, id
, onEditVideo, onMaskClick, getCopyText, showNotification } = props; , onEditVideo, onMaskClick, getCopyText, showNotification,vv,play_duration} = props;
useEffect(()=> { useEffect(()=> {
if (!isReview) { if (!isReview) {
_clipboard = new ClipboardJS(`.copybtn_item_${id}`); _clipboard = new ClipboardJS(`.copybtn_item_${id}`);
_clipboard.on('success', (e) => { _clipboard.on('success', (e) => {
showNotification('复制成功') showNotification('复制成功')
}); });
clipboardMap[id] = _clipboard clipboardMap[id] = _clipboard
} }
return () => { return () => {
@ -45,28 +45,37 @@ function VideoInReviewItem (props) {
} }
return ( return (
<div className={`${isReview ? 'videoInReviewItem' : 'nItem'} videoItem`}> <div className={`${isReview ? 'videoInReviewItem' : 'nItem'} videoItem`}>
<img className="cover" src={cover_url || "http://video.educoder.net/e7d18970482a46d2a6f0e951b504256c/snapshots/491e113950d74f1dab276097dae287dd-00005.jpg"} <img className="cover" src={cover_url || "http://video.educoder.net/e7d18970482a46d2a6f0e951b504256c/snapshots/491e113950d74f1dab276097dae287dd-00005.jpg"}
></img> ></img>
{!isReview && <div className="mask" onClick={() => onMaskClick(props)}> {!isReview && <div className="mask" onClick={() => onMaskClick(props)}>
</div>} </div>}
{!isReview && {!isReview &&
<div className="playWrap" onClick={() => onMaskClick(props)}> <div className="playWrap" onClick={() => onMaskClick(props)}>
<img className="play" src={playIcon}></img> <img className="play mp23" src={playIcon}></img>
{play_duration===0?"":<div className={"play_duration"}>累计学习时长{play_duration} h</div>}
</div> </div>
} }
<div className="square-main"> <div className="square-main">
<div className="title overflowHidden1" <div className="title overflowHidden1"
title={title && title.length > 20 ? title : ''} title={title && title.length > 20 ? title : ''}
>{title}</div> >{title}</div>
<div className="df buttonRow mb10">
<span className="time">{moment(published_at || created_at).format('YYYY-MM-DD HH:mm:ss')}</span>
</div>
<div className="df buttonRow"> <div className="df buttonRow">
{/* 2019-09-01 10:00:22 */} {/* 2019-09-01 10:00:22 */}
<span className="time">{moment(published_at || created_at).format('YYYY-MM-DD HH:mm:ss')}</span> <span className={"dianjilianicon"}>
{vv===0?"":<Tooltip title="播放次数" placement="bottom">
<i className={`icon-dianjiliang iconfont dianjilianicon`}></i>
</Tooltip> } {vv===0?"":vv}
</span>
{ isReview != true && <div> { isReview != true && <div>
<Tooltip title="编辑" placement="bottom"> <Tooltip title="编辑" placement="bottom">
<i className="icon-bianji1 iconfont" onClick={() => onEditVideo(props)} <i className="icon-bianji1 iconfont" onClick={() => onEditVideo(props)}
style={{ marginTop: '1px', display: 'inline-block'}} style={{ marginTop: '1px', display: 'inline-block'}}
></i> ></i>
</Tooltip> </Tooltip>
<Tooltip title="复制视频地址" placement="bottom"> <Tooltip title="复制视频地址" placement="bottom">

Loading…
Cancel
Save