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

This commit is contained in:
xxq250 2024-08-21 11:00:54 +08:00
parent 233642d903
commit 19c2367257
2 changed files with 6 additions and 1 deletions

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

View File

@ -77,8 +77,12 @@ class Projects::ListQuery < ApplicationQuery
end
def by_project_topic(items)
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
# 优化排序
def optimize_sorting(relations, sort_by)