Permalink
Browse files

search relevancy bump for tickets less than 50 days old.

git-svn-id: http://store.sabretechllc.com/public/jonmagic/optik/trunk@302 331dd862-6008-0410-a02f-b57fe9264243
  • Loading branch information...
1 parent 89016bb commit 33db17a1ac3d5be5fe3f3a060b35b78fd4ff6550 dcparker committed Nov 9, 2007
Showing with 3 additions and 0 deletions.
  1. +3 −0 app/models/ticket.rb
@@ -11,6 +11,9 @@ def self.fullsearch(query, options = {})
Ticket.find_by_sql(["SELECT tickets.* FROM tickets WHERE 0" + (" OR LOWER(tickets.description) LIKE ?") * tokens.length] + tokens.map {|t| '%'+t.downcase+'%'}).each do |result|
resultshash[result.id] ||= [0, nil]
resultshash[result.id][0] += 1
+ x = (Time.now - result.created_at)/86400
+ y = ((-(x^2)/200)+8.49999).to_i # Makes a bump up to 8 points on a reverse-exponential scale, from 0 to 50 days old.
+ resultshash[result.id][0] += y if y > 0
resultshash[result.id][1] = result
end
Note.find_by_sql(["SELECT notes.* FROM notes WHERE 0" + (" OR LOWER(notes.content) LIKE ?") * tokens.length] + tokens.map {|t| '%'+t.downcase+'%'}).each do |result|

0 comments on commit 33db17a

Please sign in to comment.