From 6f75f984eefda61fadee51cffb3b6e351efb00dc Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 23:12:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5=E6=94=B6?= =?UTF-8?q?=E8=97=8F=E7=9A=84=E5=AE=9E=E8=AE=AD=E9=A1=B9=E7=9B=AE=E8=BF=87?= =?UTF-8?q?=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/users/shixun_service.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/services/users/shixun_service.rb b/app/services/users/shixun_service.rb index 6b17ea379..0efe2dd1a 100644 --- a/app/services/users/shixun_service.rb +++ b/app/services/users/shixun_service.rb @@ -34,8 +34,10 @@ class Users::ShixunService def status_filter(relations) case params[:category] - when 'study', 'collect' then + when 'study' then study_shixun_status_filter(relations) + when 'collect' then + collect_shixun_status_filter(relations) when 'manage' then manage_shixun_status_filter(relations) else @@ -66,6 +68,16 @@ class Users::ShixunService relations end + def collect_shixun_status_filter relations + passed_shixun_ids = user.myshixuns.where(shixun_id: relations, status: 1).pluck(:shixun_id) + if params[:status] == 'passed' + relations = relations.where(id: passed_shixun_ids) + elsif params[:status] == 'processing' + relations = relations.where.not(id: passed_shixun_ids) + end + relations + end + def manage_shixun_status_filter(relations) if params[:status] == "publiced" relations = relations.where(public: 2)