implemented numbered paginator

This commit is contained in:
albert
2010-03-19 17:03:14 -04:00
parent be10906044
commit f112ff7c67
4 changed files with 45 additions and 56 deletions

View File

@@ -181,6 +181,7 @@ class Post < ActiveRecord::Base
increment_tags.each do |tag|
expire_cache(tag)
end
expire_cache("")
end
def set_tag_counts
@@ -515,20 +516,17 @@ class Post < ActiveRecord::Base
module CountMethods
def fast_count(tags)
count = Cache.get("pfc:#{Cache.sanitize(tags)}")
return count unless count.nil?
count = Post.find_by_tags(tags).count
expiry = (count < 100) ? 0 : (count * 4).minutes
Cache.put("pfc:#{Cache.sanitize(tags)}", count, expiry)
if count.nil?
count = Post.find_by_tags("#{tags}").count
if count > Danbooru.config.posts_per_page * 10
Cache.put("pfc:#{Cache.sanitize(tags)}", count, (count * 4).minutes)
end
end
count
end
def fast_delete_count(tags)
count = Cache.get("pfdc:#{Cache.sanitize(tags)}")
return count unless count.nil?
count = Post.find_by_tags("#{tags} status:deleted").count
expiry = (count < 100) ? 0 : (count * 4).minutes
Cache.put("pfc:#{Cache.sanitize(tags)}", count, expiry)
count
fast_count("#{tags} status:deleted")
end
end

View File

@@ -4,7 +4,7 @@ class User < ActiveRecord::Base
class Error < Exception ; end
attr_accessor :password, :old_password, :ip_addr
attr_accessible :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name
attr_accessible :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr
validates_length_of :name, :within => 2..20, :on => :create
validates_format_of :name, :with => /\A[^\s;,]+\Z/, :on => :create, :message => "cannot have whitespace, commas, or semicolons"
validates_uniqueness_of :name, :case_sensitive => false, :on => :create