added pixiv proxy, report mailer

This commit is contained in:
albert
2010-02-24 16:00:52 -05:00
parent 55700efeb1
commit cd0aa75dbc
5 changed files with 120 additions and 3 deletions

View File

@@ -9,7 +9,8 @@ class Comment < ActiveRecord::Base
attr_accessor :do_not_bump_post
scope :recent, :order => "comments.id desc", :limit => 6
scope :search_body, lambda {|query| {:conditions => ["body_index @@ plainto_tsquery(?)", query], :order => "id desc"}}
scope :search_body, lambda {|query| where("body_index @@ plainto_tsquery(?)", query)}
scope :hidden, lambda {|user| where("score < ?", user.comment_threshold)}
def update_last_commented_at
return if do_not_bump_post

View File

@@ -42,9 +42,9 @@ class Note < ActiveRecord::Base
def update_post
if Note.exists?(["is_active = ? AND post_id = ?", true, post_id])
Post.update(post_id, :last_noted_at => updated_at, :updater_id => updater_id, :updater_ip_addr => updater_ip_addr)
execute_sql("UPDATE posts SET last_noted_at = ? WHERE id = ?", updated_at, post_id)
else
Post.update(post_id, :last_noted_at => nil, :updater_id => updater_id, :updater_ip_addr => updater_ip_addr)
execute_sql("UPDATE posts SET last_noted_at = NULL WHERE id = ?", post_id)
end
end

View File

@@ -499,6 +499,20 @@ class Post < ActiveRecord::Base
end
end
module CountMethods
def fast_count(tags)
Cache.get("pfc:#{Cache.sanitize(tags)}", 24.hours) do
Post.find_by_tags(tags).count
end
end
def fast_delete_count(tags)
Cache.get("pfdc:#{Cache.sanitize(tags)}", 24.hours) do
Post.find_by_tags("#{tags} status:deleted").count
end
end
end
include FileMethods
include ImageMethods
include ModerationMethods
@@ -510,6 +524,7 @@ class Post < ActiveRecord::Base
include PoolMethods
extend SearchMethods
include VoteMethods
extend CountMethods
def reload(options = nil)
super

View File

@@ -0,0 +1,7 @@
class ReportMailer < ActionMailer::Base
default :host => Danbooru.config.server_host, :from => Danbooru.config.contact_email, :content_type => "text/html"
def moderator_report(email)
mail(:to => email, :subject => "#{Danbooru.config.app_name} - Moderator Report")
end
end