个人主页收藏的实训项目过滤

schedule_job
cxt 5 years ago
parent 4601f3fc80
commit 6f75f984ee

@ -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)

Loading…
Cancel
Save