fixes to user search

This commit is contained in:
albert
2013-02-21 12:42:41 -05:00
parent 762bbd2caf
commit 78f1d0f69a
24 changed files with 48 additions and 30 deletions

View File

@@ -13,7 +13,7 @@ class AdvertisementsController < ApplicationController
end
def index
@advertisements = Advertisement.all
@advertisements = Advertisement.order("id desc").all
@start_date = 1.month.ago.to_date
@end_date = Date.today
end

View File

@@ -2,7 +2,7 @@ class ArtistVersionsController < ApplicationController
respond_to :html, :xml, :json
def index
@artist_versions = ArtistVersion.search(params[:search]).paginate(params[:page])
@artist_versions = ArtistVersion.search(params[:search]).order("id desc").paginate(params[:page])
respond_with(@artist_versions)
end
end

View File

@@ -18,7 +18,7 @@ class ArtistsController < ApplicationController
end
def index
@artists = Artist.search(params[:search]).paginate(params[:page])
@artists = Artist.search(params[:search]).order("id desc").paginate(params[:page])
respond_with(@artists) do |format|
format.xml do
render :xml => @artists.to_xml(:include => [:urls])

View File

@@ -10,7 +10,7 @@ class BansController < ApplicationController
end
def index
@search = Ban.search(params[:search])
@search = Ban.search(params[:search]).order("id desc")
@bans = @search.paginate(params[:page])
end

View File

@@ -15,7 +15,7 @@ class DmailsController < ApplicationController
def index
@search = Dmail.visible.search(params[:search])
@dmails = @search.paginate(params[:page]).order("dmails.created_at desc")
@dmails = @search.order("dmails.created_at desc").paginate(params[:page])
respond_with(@dmails)
end

View File

@@ -17,7 +17,7 @@ class ForumPostsController < ApplicationController
def index
@search = ForumPost.active.search(params[:search])
@forum_posts = @search.paginate(params[:page]).order("forum_posts.id DESC")
@forum_posts = @search.order("forum_posts.id DESC").paginate(params[:page])
respond_with(@forum_posts)
end

View File

@@ -19,7 +19,7 @@ class ForumTopicsController < ApplicationController
def index
@search = ForumTopic.active.search(params[:search])
@forum_topics = @search.paginate(params[:page]).order("is_sticky DESC, updated_at DESC")
@forum_topics = @search.order("is_sticky DESC, updated_at DESC").paginate(params[:page])
respond_with(@forum_topics)
end

View File

@@ -12,7 +12,7 @@ class IpBansController < ApplicationController
def index
@search = IpBan.search(params[:search])
@ip_bans = @search.paginate(params[:page])
@ip_bans = @search.order("id desc").paginate(params[:page])
end
def destroy

View File

@@ -14,7 +14,7 @@ class JanitorTrialsController < ApplicationController
def index
@search = JanitorTrial.search(params[:search])
@janitor_trials = @search.paginate(params[:page])
@janitor_trials = @search.order("id desc").paginate(params[:page])
respond_with(@janitor_trials)
end

View File

@@ -3,7 +3,7 @@ class NewsUpdatesController < ApplicationController
respond_to :html
def index
@news_updates = NewsUpdate.paginate(params[:page])
@news_updates = NewsUpdate.order("id desc").paginate(params[:page])
respond_with(@news_updates)
end

View File

@@ -64,7 +64,7 @@ private
def index_by_note
@search = Note.search(params[:search])
@notes = @search.paginate(params[:page])
@notes = @search.order("id desc").paginate(params[:page])
respond_with(@notes) do |format|
format.html {render :action => "index_by_note"}
end

View File

@@ -16,7 +16,7 @@ class PoolsController < ApplicationController
def index
@search = Pool.active.search(params[:search])
@pools = @search.paginate(params[:page]).order("updated_at desc")
@pools = @search.order("updated_at desc").paginate(params[:page])
respond_with(@pools)
end

View File

@@ -9,7 +9,7 @@ class PostAppealsController < ApplicationController
end
def index
@search = PostAppeal.search(params[:search]).order("id desc")
@search = PostAppeal.order("id desc").search(params[:search])
@post_appeals = @search.paginate(params[:page])
end

View File

@@ -9,7 +9,7 @@ class PostFlagsController < ApplicationController
end
def index
@search = PostFlag.search(params[:search]).order("id desc")
@search = PostFlag.order("id desc").search(params[:search])
@post_flags = @search.paginate(params[:page])
end

View File

@@ -16,7 +16,7 @@ class TagSubscriptionsController < ApplicationController
def index
@user = CurrentUser.user
@search = TagSubscription.owned_by(@user).search(params[:search])
@search = TagSubscription.owned_by(@user).order("name").search(params[:search])
@tag_subscriptions = @search.paginate(params[:page])
respond_with(@tag_subscriptions)
end

View File

@@ -16,7 +16,7 @@ class UsersController < ApplicationController
def index
@search = User.search(params[:search])
@users = @search.paginate(params[:page]).order("users.name")
@users = @search.order("users.id desc").paginate(params[:page])
respond_with(@users)
end

View File

@@ -3,7 +3,7 @@ class WikiPageVersionsController < ApplicationController
def index
@search = WikiPageVersion.search(params[:search])
@wiki_page_versions = @search.paginate(params[:page])
@wiki_page_versions = @search.order("id desc").paginate(params[:page])
respond_with(@wiki_page_versions)
end

View File

@@ -16,7 +16,7 @@ class WikiPagesController < ApplicationController
def index
@search = WikiPage.search(params[:search])
@wiki_pages = @search.paginate(params[:page])
@wiki_pages = @search.order("id desc").paginate(params[:page])
respond_with(@wiki_pages) do |format|
format.html do
if @wiki_pages.count == 1

View File

@@ -258,6 +258,12 @@ class Artist < ActiveRecord::Base
when /./
q = q.any_name_matches(params[:name])
end
if params[:sort] == "Name"
q = q.reorder("name")
else
q = q.reorder("id desc")
end
if params[:id].present?
q = q.where("id = ?", params[:id])

View File

@@ -14,6 +14,12 @@ class ArtistVersion < ActiveRecord::Base
q = q.where("artist_id = ?", params[:artist_id].to_i)
end
if params[:sort] == "Name"
q = q.reorder("name")
else
q = q.reorder("id desc")
end
q
end

View File

@@ -220,7 +220,8 @@ class User < ActiveRecord::Base
def level_hash
return {
"Member" => Levels::MEMBER,
"Privileged" => Levels::PRIVILEGED,
"Gold" => Levels::PRIVILEGED,
"Platinum" => Levels::PLATINUM,
"Builder" => Levels::BUILDER,
"Contributor" => Levels::CONTRIBUTOR,
"Janitor" => Levels::JANITOR,
@@ -427,13 +428,13 @@ class User < ActiveRecord::Base
def favorite_limit
return nil
if is_privileged?
20_000
elsif is_platinum?
nil
else
4_000
end
# if is_privileged?
# 20_000
# elsif is_platinum?
# nil
# else
# 4_000
# end
end
end

View File

@@ -18,7 +18,7 @@
<tbody>
<% @artist_versions.each do |artist_version| %>
<tr class="<%= cycle 'even', 'odd' %>">
<td><%= link_to h(artist_version.name), artist_versions_path(:artist_id => artist_version.artist_id) %></td>
<td><%= link_to h(artist_version.name), artist_versions_path(:search => {:artist_id => artist_version.artist_id}) %></td>
<td><%= h artist_version.other_names %></td>
<td><%= h artist_version.group_name %></td>
<td><%= time_ago_in_words_tagged artist_version.created_at %></td>
@@ -31,7 +31,7 @@
</table>
</div>
<%= sequential_paginator(@artist_versions) %>
<%= numbered_paginator(@artist_versions, :count => (params[:search].present? ? nil : 1_000_000)) %>
</div>
</div>

View File

@@ -9,6 +9,11 @@
<%= text_field "search", "name" %>
<p class="hint">You can search on any name or URL</p>
</div>
<div class="input">
<label>Sort</label>
<%= select "search", "sort", ["Date", "Name"] %>
</div>
<%= submit_tag "Search" %>
<% end %>
</div>

View File

@@ -4,8 +4,8 @@
<%= search_field "name_matches", :label => "Name" %>
<div class="input">
<label for="search_level">Min Level</label>
<%= select("search", "min_level", User.level_hash.to_a) %>
<label for="search_level">Level</label>
<%= select("search", "level", [""] + User.level_hash.to_a) %>
</div>
<%= submit_tag "Search" %>