From 19c2367257c1a8f4ef5696d879247d06b94770fd Mon Sep 17 00:00:00 2001 From: xxq250 Date: Wed, 21 Aug 2024 11:00:54 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E4=B8=AA=E6=A0=87=E7=AD=BE=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/concerns/matchable.rb | 1 + app/queries/projects/list_query.rb | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/matchable.rb b/app/models/concerns/matchable.rb index 0640e7c74..27e5a0dda 100644 --- a/app/models/concerns/matchable.rb +++ b/app/models/concerns/matchable.rb @@ -7,6 +7,7 @@ module Matchable scope :with_project_type, ->(project_type) { where(project_type: project_type) if Project.project_types.include?(project_type) } scope :by_name_or_identifier, ->(search) { where("name like :search or identifier LIKE :search", :search => "%#{search.split(" ").join('|')}%") unless search.blank? } scope :with_project_topic, ->(topic_id) {joins(:project_topics).where(project_topics: {id: topic_id}) unless topic_id.blank?} + scope :with_project_topic_name, ->(topic_name) {joins(:project_topics).where(project_topics: {name: topic_name}) unless topic_name.blank?} end end diff --git a/app/queries/projects/list_query.rb b/app/queries/projects/list_query.rb index 09a02010c..737cd7c2d 100644 --- a/app/queries/projects/list_query.rb +++ b/app/queries/projects/list_query.rb @@ -77,7 +77,11 @@ class Projects::ListQuery < ApplicationQuery end def by_project_topic(items) - items.with_project_topic(params[:topic_id]) + if params[:topic_name].present? + items.with_project_topic_name(params[:topic_name].to_s.split(",")) + else + items.with_project_topic(params[:topic_id]) + end end # 优化排序