From 213fb8cd0906a1ae667c8bd94e3671c178c08852 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 24 Feb 2020 17:45:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=BA=E8=83=BD=E7=BB=84=E5=8D=B7=E7=9A=84?= =?UTF-8?q?=E5=8F=AF=E9=80=89=E9=A2=98=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/queries/optional_item_query.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/queries/optional_item_query.rb b/app/queries/optional_item_query.rb index ea3bca043..61ebf8b69 100644 --- a/app/queries/optional_item_query.rb +++ b/app/queries/optional_item_query.rb @@ -22,10 +22,12 @@ class OptionalItemQuery < ApplicationQuery items = ItemBank.where(container_id: hacks.pluck(:id), container_type: "Hack").or(ItemBank.where(id: items.pluck(:id))) end - # 来源 public = source.present? ? source.to_i : 1 - public = public == 2 ? [0, 1] : public - items = items.where(public: public) + if public == 1 + items = items.where(public: 1) + elsif public == 0 + items = items.where(user_id: User.current.id) + end # 难度 diff = difficulty ? difficulty.to_i : 1