Improved ticket search.
This commit is contained in:
parent
4f081d9671
commit
df141b153a
2 changed files with 6 additions and 2 deletions
|
@ -478,7 +478,11 @@ class TicketsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# do query
|
# do query
|
||||||
tickets_all = Ticket.where(conditions).where( '( title LIKE ? OR number LIKE ? )', "%#{query}%", "%#{query}%" ).limit(limit).order(:created_at)
|
tickets_all = Ticket.where(conditions).
|
||||||
|
where( '( title LIKE ? OR number LIKE ? OR ticket_articles.body LIKE ? OR ticket_articles.from LIKE ? OR ticket_articles.to LIKE ? OR ticket_articles.subject LIKE ?)', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%" ).
|
||||||
|
joins(:ticket_articles).
|
||||||
|
limit(limit).
|
||||||
|
order(:created_at)
|
||||||
|
|
||||||
# build result list
|
# build result list
|
||||||
tickets = []
|
tickets = []
|
||||||
|
|
|
@ -4,7 +4,7 @@ class Ticket < ApplicationModel
|
||||||
before_destroy :destroy_dependencies
|
before_destroy :destroy_dependencies
|
||||||
|
|
||||||
belongs_to :group
|
belongs_to :group
|
||||||
has_many :articles, :after_add => :cache_update, :after_remove => :cache_update
|
has_many :ticket_articles, :class_name => 'Ticket::Article', :after_add => :cache_update, :after_remove => :cache_update
|
||||||
belongs_to :organization
|
belongs_to :organization
|
||||||
belongs_to :ticket_state, :class_name => 'Ticket::State'
|
belongs_to :ticket_state, :class_name => 'Ticket::State'
|
||||||
belongs_to :ticket_priority, :class_name => 'Ticket::Priority'
|
belongs_to :ticket_priority, :class_name => 'Ticket::Priority'
|
||||||
|
|
Loading…
Reference in a new issue