Merge branch 'develop' of http://bdgit.educoder.net/Hjqreturn/pgfqe6ch8 into develop
commit
b3ffa73ed1
@ -1 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><meta name="renderer" content="webkit"/><meta name="force-rendering" content="webkit"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>Educoder</title><script type="text/javascript">window.__isR=!0</script><link rel="stylesheet" href="/react/build/css/css_min_all.css"><link rel="stylesheet" href="/assets/iconfont/iconfont.css"><link href="/react/build/./static/css/main.e1b0d6a5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="md_div" style="display:none"></div><div id="root" class="page -layout-v -fit"></div><div id="picture_display" style="display:none"></div><script type="text/javascript" src="/react/build/js/js_min_all.js"></script><script type="text/javascript" src="/assets/kindeditor/kindeditor.js"></script><script type="text/javascript" src="/react/build/js/create_kindeditor.js"></script><script type="text/javascript" src="/javascripts/educoder/edu_application.js"></script><script type="text/javascript" src="/react/build/./static/js/main.1d0aa33a.js"></script></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><meta name="renderer" content="webkit"/><meta name="force-rendering" content="webkit"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>Educoder</title><script type="text/javascript">window.__isR=!0</script><link rel="stylesheet" href="/react/build/css/css_min_all.css"><link rel="stylesheet" href="/assets/iconfont/iconfont.css"><link href="/react/build/./static/css/main.e1b0d6a5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="md_div" style="display:none"></div><div id="root" class="page -layout-v -fit"></div><div id="picture_display" style="display:none"></div><script type="text/javascript" src="/react/build/js/js_min_all.js"></script><script type="text/javascript" src="/assets/kindeditor/kindeditor.js"></script><script type="text/javascript" src="/react/build/js/create_kindeditor.js"></script><script type="text/javascript" src="/javascripts/educoder/edu_application.js"></script><script type="text/javascript" src="/react/build/./static/js/main.f14d00a5.js"></script></body></html>
|
@ -0,0 +1,24 @@
|
||||
class AddEvaluateCountToShixuns < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :shixuns, :evaluate_count, :integer, default: 0
|
||||
|
||||
limit = 100
|
||||
total = Shixun.count
|
||||
|
||||
((total / 100) + 1).times do |index|
|
||||
shixun_ids = Shixun.order(:id).limit(limit).offset(index * limit).pluck(:id)
|
||||
return if shixun_ids.blank?
|
||||
|
||||
count_map = Game.joins(:challenge).where(challenges: { shixun_id: shixun_ids }).group('shixun_id').sum(:evaluate_count)
|
||||
|
||||
id_str = count_map.keys.join(',')
|
||||
str = count_map.map { |shixun_id, count| "WHEN #{shixun_id} THEN #{count}" }.join(' ')
|
||||
|
||||
execute "UPDATE shixuns SET evaluate_count = CASE id #{str} END WHERE id IN (#{id_str})"
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :shixuns, :evaluate_count
|
||||
end
|
||||
end
|
Loading…
Reference in new issue