FIX search projects relation repository

This commit is contained in:
Jasder 2020-03-19 17:15:56 +08:00
parent ea74a7ab0a
commit fe9ac94222
1 changed files with 1 additions and 1 deletions

View File

@ -3,7 +3,7 @@ module Matchable
included do
scope :like, lambda { |keywords|
where("name LIKE ?", "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
joins(:repository).where(%w[ projects.name projects.identifier repositories.identifier ].map { |f| "LOWER(#{f}) LIKE :q" }.join(' OR '), q: "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
}
scope :with_project_category, ->(category_id) { where(project_category_id: category_id) unless category_id.blank? }
scope :with_project_language, ->(language_id) { where(project_language_id: language_id) unless language_id.blank? }