Browse Source

fixed 项目列表支持多个标签名称查询

pull/347/head
xxq250 1 year ago
parent
commit
11743355ef
2 changed files with 6 additions and 1 deletions
  1. +1
    -0
      app/models/concerns/matchable.rb
  2. +5
    -1
      app/queries/projects/list_query.rb

+ 1
- 0
app/models/concerns/matchable.rb View File

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

+ 5
- 1
app/queries/projects/list_query.rb View File

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

# 优化排序


Loading…
Cancel
Save