You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/lib/tasks/check_reponame.rake

28 lines
982 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

namespace :myshixun do
task check_reponame: :environment do
# 如果是选择题的则跳过否则reponame 为空的则为异常
myshixuns = Myshixun.where("repo_name is null and created_at > '2019-07-20 00:00:00'")
myshixuns.each do |myshixun|
shixun = myshixun.shixun
challenges = shixun.challenges
# 不是纯选择题的情况
if challenges.select{|challenge| challenge.st.to_i == 0}.size > 0
puts myshixun.games.first.try(:identifier)
end
end
end
task choose_repo: :environment do
myshixuns = Myshixun.where("repo_name is null and created_at > '2019-07-20 00:00:00'")
myshixuns.each do |myshixun|
shixun = myshixun.shixun
challenges = shixun.challenges
# 如果是选择题则把myshixuns表的repo_name改成-1
if challenges.select{|challenge| challenge.st.to_i == 1}.size == challenges.count
myshixun.update_attributes(:repo_name => "-1")
end
end
end
end