From 729c079738900616811209a3c8f9274ae4b3b273 Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Fri, 8 Mar 2019 12:16:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4gpid=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E7=9A=84myshixun?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- lib/tasks/delete_error_myshixun.rake | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 lib/tasks/delete_error_myshixun.rake diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index f147b9b2..e50827e3 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -384,7 +384,7 @@ class ShixunsController < ApplicationController shixun_id = shixun_id & my_shixun_ids end - @shixuns = Shixun.select([:id, :name, :user_id, :challenges_count, :visits, :status, :myshixuns_count, :trainee, :use_scope, :identifier, :image_text]).where(:id => shixun_id, :hidden => 0, :trainee => diff, :status => status).includes(:challenges, :schools, :shixun_members, :users) + @shixuns = Shixun.select([:id, :name, :user_id, :challenges_count, :visits, :status, :myshixuns_count, :trainee, :use_scope, :identifier, :image_text, :averge_star]).where(:id => shixun_id, :hidden => 0, :trainee => diff, :status => status).includes(:challenges, :schools, :shixun_members, :users) if search.present? search_users_id = User.select([:id]).where("concat(lastname, firstname) like '%#{search}%'") diff --git a/lib/tasks/delete_error_myshixun.rake b/lib/tasks/delete_error_myshixun.rake new file mode 100644 index 00000000..269b4536 --- /dev/null +++ b/lib/tasks/delete_error_myshixun.rake @@ -0,0 +1,11 @@ +namespace :myshixun do + desc "delete gpid is no" + task :delete_error_myshixuns => :environment do + begin + myshixuns = Myshixun.where(gpid: nil) + myshixuns.delete_all + rescue Exception => e + puts e + end + end +end