Code style fixes

This commit is contained in:
Jyri-Petteri Paloposki 2020-10-10 02:27:42 +03:00
parent c6bbc67dab
commit d8acf60049
72 changed files with 458 additions and 594 deletions

View file

@ -1,5 +1,4 @@
module Search
class SearchResults
attr_reader :results
@ -27,28 +26,26 @@ module Search
def incomplete_todos(terms)
@user.todos.
where("(todos.description " + Common.like_operator + " ? OR todos.notes " + Common.like_operator + " ?) AND todos.completed_at IS NULL", terms, terms).
includes(Todo::DEFAULT_INCLUDES).
reorder(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC"))
where("(todos.description " + Common.like_operator + " ? OR todos.notes " + Common.like_operator + " ?) AND todos.completed_at IS NULL", terms, terms)
.includes(Todo::DEFAULT_INCLUDES)
.reorder(Arel.sql("todos.due IS NULL, todos.due ASC, todos.created_at ASC"))
end
def complete_todos(terms)
@user.todos.
where("(todos.description " + Common.like_operator + " ? OR todos.notes " + Common.like_operator + " ?) AND NOT (todos.completed_at IS NULL)", terms, terms).
includes(Todo::DEFAULT_INCLUDES).
reorder("todos.completed_at DESC")
where("(todos.description " + Common.like_operator + " ? OR todos.notes " + Common.like_operator + " ?) AND NOT (todos.completed_at IS NULL)", terms, terms)
.includes(Todo::DEFAULT_INCLUDES)
.reorder("todos.completed_at DESC")
end
def todo_tags_by_name(terms)
Tagging.find_by_sql([
"SELECT DISTINCT tags.name as name "+
"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 " + Common.like_operator + " ? ", @user.id, terms])
"SELECT DISTINCT tags.name as name " +
"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 " + Common.like_operator + " ? ", @user.id, terms])
end
end
end