From c91552399b4039fe7c41404989892838687c337d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 2 Jan 2020 16:41:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/queries/item_bank_query.rb | 6 +++++- app/views/item_banks/_item.json.jbuilder | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/queries/item_bank_query.rb b/app/queries/item_bank_query.rb index eb57422df..ecd52184c 100644 --- a/app/queries/item_bank_query.rb +++ b/app/queries/item_bank_query.rb @@ -23,7 +23,11 @@ class ItemBankQuery < ApplicationQuery items = items.joins(:sub_discipline).where(sub_disciplines: {discipline_id: params[:discipline_id]}) end - items = items.where(item_type: params[:item_type].to_i) if params[:item_type].present? + if params[:oj_status].present? && params[:item_type] == "PROGRAM" + items = items.joins("join hacks on hacks.id=item_banks.container_id and item_banks.container_type='Hack'").where(hacks: {status: params[:oj_status]}) + end + + items = items.where(item_type: params[:item_type]) if params[:item_type].present? items = items.where(difficulty: params[:difficulty].to_i) if params[:difficulty].present? items = items.where("name like ?", "%#{params[:keyword].strip}%") if params[:keyword].present? diff --git a/app/views/item_banks/_item.json.jbuilder b/app/views/item_banks/_item.json.jbuilder index 92561f550..24e6e358d 100644 --- a/app/views/item_banks/_item.json.jbuilder +++ b/app/views/item_banks/_item.json.jbuilder @@ -6,6 +6,6 @@ json.choices item.item_choices do |choice| end if item.item_type == "PROGRAM" json.program_attr do - json.(item.container, :description, :language, :difficult) + json.(item.container, :description, :language, :difficult, :status, :identifier) end end \ No newline at end of file