rake任务调整

dev_new_shixunsrepository
cxt 5 years ago
parent a6dbd1450f
commit 676a73ed6b

@ -7,7 +7,7 @@ namespace :sync_program do
unless Hack.where(name: program.name).exists? unless Hack.where(name: program.name).exists?
strip_des = strip_html(program.description, 5000) strip_des = strip_html(program.description, 5000)
description = strip_des.present? ? strip_des : program.name description = strip_des.present? ? strip_des : program.name
hack_params = {name: program.name[0..59], description: description, difficult: 1, open_or_not: 1, score: 200, sub_discipline_id: program.oj_sub_discipline_id} hack_params = {name: program.name[0..59], description: description, difficult: 1, open_or_not: 1, score: 200, status:0, time_limit: 3, sub_discipline_id: program.oj_sub_discipline_id}
puts "language::::#{program.language}" puts "language::::#{program.language}"
puts "program_bank::::#{program.id}" puts "program_bank::::#{program.id}"
hack = Hack.new(hack_params) hack = Hack.new(hack_params)
@ -24,11 +24,11 @@ namespace :sync_program do
end end
end end
# 新建知识点 # 新建知识点
hack_code_params = {code: program.standard_code, language: program.oj_language} hack_code_params = {code: Base64.encode64(program.standard_code), language: program.oj_language}
hack_codes = hack.hack_codes.new(hack_code_params) hack_codes = hack.hack_codes.new(hack_code_params)
hack_codes.modify_time = Time.now hack_codes.modify_time = Time.now
hack_codes.save! hack_codes.save!
new_item_params = {name: program.name, sub_discipline_id: program.oj_sub_discipline_id, container: hack, item_type: 'PROGRAM', public: 1, difficulty: 1, user_id: 1} new_item_params = {name: program.name, sub_discipline_id: program.oj_sub_discipline_id, container: hack, item_type: 'PROGRAM', public: 0, difficulty: 1, user_id: 1}
ItemBank.create!(new_item_params) ItemBank.create!(new_item_params)
end end
puts hack.id puts hack.id

Loading…
Cancel
Save