fix user listing and search on non-US locale

This commit is contained in:
Kuba Brecka 2013-02-10 12:18:11 +01:00
parent 4b0eec334f
commit d0c1d94918
2 changed files with 9 additions and 9 deletions

View file

@ -3,7 +3,7 @@ class Admin::UsersController < Admin::AdminController
def index def index
# Sort order # Sort order
if params[:query] == "active" 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 else
@users = User.order("created_at DESC, username") @users = User.order("created_at DESC, username")
end end

View file

@ -21,7 +21,7 @@ module Search
NULL AS color NULL AS color
FROM users AS u FROM users AS u
JOIN users_search s on s.id = u.id 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 ORDER BY last_posted_at desc
" "
end end
@ -36,13 +36,13 @@ module Search
FROM topics AS ft FROM topics AS ft
JOIN posts AS p ON p.topic_id = ft.id AND p.post_number = 1 JOIN posts AS p ON p.topic_id = ft.id AND p.post_number = 1
JOIN posts_search s on s.id = p.id 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.deleted_at IS NULL
AND ft.visible AND ft.visible
AND ft.archetype <> '#{Archetype.private_message}' AND ft.archetype <> '#{Archetype.private_message}'
ORDER BY ORDER BY
TS_RANK_CD(TO_TSVECTOR('english', ft.title), TO_TSQUERY(:query)) desc, TS_RANK_CD(TO_TSVECTOR('english', ft.title), TO_TSQUERY('english', :query)) desc,
TS_RANK_CD(search_data, TO_TSQUERY(:query)) desc, TS_RANK_CD(search_data, TO_TSQUERY('english', :query)) desc,
bumped_at desc" bumped_at desc"
end end
@ -57,13 +57,13 @@ module Search
FROM topics AS ft FROM topics AS ft
JOIN posts AS p ON p.topic_id = ft.id AND p.post_number <> 1 JOIN posts AS p ON p.topic_id = ft.id AND p.post_number <> 1
JOIN posts_search s on s.id = p.id 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.deleted_at IS NULL and p.deleted_at IS NULL
AND ft.visible AND ft.visible
AND ft.archetype <> '#{Archetype.private_message}' AND ft.archetype <> '#{Archetype.private_message}'
ORDER BY ORDER BY
TS_RANK_CD(TO_TSVECTOR('english', ft.title), TO_TSQUERY(:query)) desc, TS_RANK_CD(TO_TSVECTOR('english', ft.title), TO_TSQUERY('english', :query)) desc,
TS_RANK_CD(search_data, TO_TSQUERY(:query)) desc, TS_RANK_CD(search_data, TO_TSQUERY('english', :query)) desc,
bumped_at desc" bumped_at desc"
end end
@ -76,7 +76,7 @@ module Search
c.color c.color
FROM categories AS c FROM categories AS c
JOIN categories_search s on s.id = c.id 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 ORDER BY topics_month desc
" "
end end