diff --git a/app/models/concerns/matchable.rb b/app/models/concerns/matchable.rb index 0640e7c7..27e5a0dd 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 09a02010..737cd7c2 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 # 优化排序