From a6aff160998903a3b095c21c4b604fc0d036e4d0 Mon Sep 17 00:00:00 2001 From: chiu Date: Tue, 26 May 2020 20:41:54 +0800 Subject: [PATCH] accelerate speed about 70 times --- app/controllers/archives_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/archives_controller.rb b/app/controllers/archives_controller.rb index b1a4e59..de151eb 100644 --- a/app/controllers/archives_controller.rb +++ b/app/controllers/archives_controller.rb @@ -359,8 +359,8 @@ F cats = files_by_cateogry.keys.collect do |cat| def check_cat_sort_data categories_temp = ModuleApp.where(:key => "archive").first.categories categories_temp.each do |category| - archive_cat = ArchiveCategory.all.select{ |value| value.category_id.to_s == category.id.to_s} - if archive_cat.length == 0 + archive_cat = ArchiveCategory.where(:category_id => category.id) + if archive_cat.count == 0 ArchiveCategory.create(category_id: category.id.to_s) end end