mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-26 12:08:47 +01:00
Rewrite tag search SQL to use JOIN instead of WHERE when appropriate.
Signed-off-by: Reinier Balt <lrbalt@gmail.com>
This commit is contained in:
parent
2472866baa
commit
609cd181b6
1 changed files with 4 additions and 5 deletions
|
|
@ -13,12 +13,11 @@ class SearchController < ApplicationController
|
|||
# TODO: limit search to tags on todos
|
||||
@found_tags = Tagging.find_by_sql([
|
||||
"SELECT DISTINCT tags.name as name "+
|
||||
"FROM tags, taggings, todos "+
|
||||
"FROM tags "+
|
||||
"LEFT JOIN taggings ON tags.id = taggings.tag_id "+
|
||||
"LEFT JOIN todos ON taggings.taggable_id = todos.id "+
|
||||
"WHERE todos.user_id=? "+
|
||||
"AND tags.name LIKE ? " +
|
||||
"AND tags.id = taggings.tag_id " +
|
||||
"AND taggings.taggable_id = todos.id ", current_user.id, terms])
|
||||
#current_user.tags.find(:all, :conditions => ["name LIKE ?", terms])
|
||||
"AND tags.name LIKE ? ", current_user.id, terms])
|
||||
|
||||
@count = @found_todos.size + @found_projects.size + @found_notes.size + @found_contexts.size + @found_tags.size
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue