From d0c1d949182538bb8b27968b6699ccdd49f6210e Mon Sep 17 00:00:00 2001 From: Kuba Brecka Date: Sun, 10 Feb 2013 12:18:11 +0100 Subject: [PATCH] fix user listing and search on non-US locale --- app/controllers/admin/users_controller.rb | 2 +- lib/search.rb | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index dc3651fce9f..910f8aa041a 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -3,7 +3,7 @@ class Admin::UsersController < Admin::AdminController def index # Sort order if params[:query] == "active" - @users = User.order("COALESCE(last_seen_at, '01-01-1970') DESC, username") + @users = User.order("COALESCE(last_seen_at, '1970-01-01') DESC, username") else @users = User.order("created_at DESC, username") end diff --git a/lib/search.rb b/lib/search.rb index ab186e4eebc..e91486da791 100644 --- a/lib/search.rb +++ b/lib/search.rb @@ -21,7 +21,7 @@ module Search NULL AS color FROM users AS u JOIN users_search s on s.id = u.id - WHERE s.search_data @@ TO_TSQUERY(:query) + WHERE s.search_data @@ TO_TSQUERY('english', :query) ORDER BY last_posted_at desc " end @@ -36,13 +36,13 @@ module Search FROM topics AS ft JOIN posts AS p ON p.topic_id = ft.id AND p.post_number = 1 JOIN posts_search s on s.id = p.id - WHERE s.search_data @@ TO_TSQUERY(:query) + WHERE s.search_data @@ TO_TSQUERY('english', :query) AND ft.deleted_at IS NULL AND ft.visible AND ft.archetype <> '#{Archetype.private_message}' ORDER BY - TS_RANK_CD(TO_TSVECTOR('english', ft.title), TO_TSQUERY(:query)) desc, - TS_RANK_CD(search_data, TO_TSQUERY(:query)) desc, + TS_RANK_CD(TO_TSVECTOR('english', ft.title), TO_TSQUERY('english', :query)) desc, + TS_RANK_CD(search_data, TO_TSQUERY('english', :query)) desc, bumped_at desc" end @@ -57,13 +57,13 @@ module Search FROM topics AS ft JOIN posts AS p ON p.topic_id = ft.id AND p.post_number <> 1 JOIN posts_search s on s.id = p.id - WHERE s.search_data @@ TO_TSQUERY(:query) + WHERE s.search_data @@ TO_TSQUERY('english', :query) AND ft.deleted_at IS NULL and p.deleted_at IS NULL AND ft.visible AND ft.archetype <> '#{Archetype.private_message}' ORDER BY - TS_RANK_CD(TO_TSVECTOR('english', ft.title), TO_TSQUERY(:query)) desc, - TS_RANK_CD(search_data, TO_TSQUERY(:query)) desc, + TS_RANK_CD(TO_TSVECTOR('english', ft.title), TO_TSQUERY('english', :query)) desc, + TS_RANK_CD(search_data, TO_TSQUERY('english', :query)) desc, bumped_at desc" end @@ -76,7 +76,7 @@ module Search c.color FROM categories AS c JOIN categories_search s on s.id = c.id - WHERE s.search_data @@ TO_TSQUERY(:query) + WHERE s.search_data @@ TO_TSQUERY('english', :query) ORDER BY topics_month desc " end