关闭浏览器

dev_home
daiao 5 years ago
parent 725fd3fc34
commit 6098ecd3ca

@ -768,8 +768,8 @@ class GamesController < ApplicationController
# REDO:需要添加详细的说明
def cost_time
#return if @game.status >= 2
cost_time = (Time.now.to_i - @game.close_browse_time.to_i) + @game.cost_time.to_i
@game.update_attributes(close_browse_time: Time.now, cost_time: cost_time)
cost_time = (Time.now.to_i - @game.play_time.to_i) + @game.cost_time.to_i
@game.update_attributes(play_time: Time.now, cost_time: cost_time, play_sign: 0)
end
# 同步challenge的更新时间
@ -939,7 +939,13 @@ class GamesController < ApplicationController
game.update_attributes(status: 0, open_time: Time.now) if game.open_time.blank? || game.status == 3
# 开启实训更新myshixuns的时间方便跟踪用于的学习进度。
game.myshixun.update_column(:updated_at, Time.now)
@game.update_attribute(:close_browse_time, Time.now) if game.status < 2 && @game.close_browse_time.nil?
# 如果异常关闭的话 更新完关卡的时间
if game.status < 2 && @game.play_sign == 0
@game.update_attributes(play_time: Time.now, play_sign: 1)
elsif game.status < 2 && @game.play_sign == 1
cost_time = Time.now.to_i - (@game.play_time.presence || Time.now).to_i + cost_time.to_i
@game.update_attributes(play_time: Time.now, cost_time: cost_time, play_sign: 1)
end
end
# vnc连接

@ -1,5 +0,0 @@
class AddCloseBrowserTimeForGames < ActiveRecord::Migration[5.2]
def change
add_column :games, :close_browse_time, :timestamp
end
end

@ -0,0 +1,7 @@
class AddCloseBrowserTimeForGames < ActiveRecord::Migration[5.2]
def change
remove_column :games,:close_browse_time
add_column :games, :play_time, :timestamp
add_column :games, :play_sign, :integer, :default => 0
end
end
Loading…
Cancel
Save