fixes #837
This commit is contained in:
@@ -58,7 +58,29 @@ class Note < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
module ApiMethods
|
||||
def serializable_hash(options = {})
|
||||
options ||= {}
|
||||
options[:except] ||= []
|
||||
options[:except] += hidden_attributes
|
||||
unless options[:builder]
|
||||
options[:methods] ||= []
|
||||
options[:methods] += [:creator_name]
|
||||
end
|
||||
hash = super(options)
|
||||
hash
|
||||
end
|
||||
|
||||
def to_xml(options = {}, &block)
|
||||
options ||= {}
|
||||
options[:procs] ||= []
|
||||
options[:procs] << lambda {|options, record| options[:builder].tag!("creator-name", record.creator_name)}
|
||||
super(options, &block)
|
||||
end
|
||||
end
|
||||
|
||||
extend SearchMethods
|
||||
include ApiMethods
|
||||
|
||||
def presenter
|
||||
@presenter ||= NotePresenter.new(self)
|
||||
@@ -89,7 +111,7 @@ class Note < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def creator_name
|
||||
User.id_to_name(creator_id)
|
||||
User.id_to_name(creator_id).tr("_", " ")
|
||||
end
|
||||
|
||||
def update_post
|
||||
|
||||
@@ -537,7 +537,7 @@ class Post < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def uploader_name
|
||||
User.id_to_name(uploader_id)
|
||||
User.id_to_name(uploader_id).tr("_", " ")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -837,20 +837,15 @@ class Post < ActiveRecord::Base
|
||||
options ||= {}
|
||||
options[:except] ||= []
|
||||
options[:except] += hidden_attributes
|
||||
# options[:methods] += [:uploader_name, :has_large]
|
||||
unless options[:builder]
|
||||
options[:methods] ||= []
|
||||
options[:methods] += [:uploader_name, :has_large]
|
||||
end
|
||||
hash = super(options)
|
||||
hash
|
||||
end
|
||||
|
||||
def to_json(options = {})
|
||||
options ||= {}
|
||||
options[:methods] ||= []
|
||||
options[:methods] += [:uploader_name, :has_large]
|
||||
super(options)
|
||||
end
|
||||
|
||||
def to_xml(options = {}, &block)
|
||||
# to_xml ignores the serializable_hash method
|
||||
options ||= {}
|
||||
options[:procs] ||= []
|
||||
options[:procs] << lambda {|options, record| options[:builder].tag!("uploader-name", record.uploader_name)}
|
||||
|
||||
@@ -364,6 +364,27 @@ class Upload < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
module ApiMethods
|
||||
def serializable_hash(options = {})
|
||||
options ||= {}
|
||||
options[:except] ||= []
|
||||
options[:except] += hidden_attributes
|
||||
unless options[:builder]
|
||||
options[:methods] ||= []
|
||||
options[:methods] += [:uploader_name]
|
||||
end
|
||||
hash = super(options)
|
||||
hash
|
||||
end
|
||||
|
||||
def to_xml(options = {}, &block)
|
||||
options ||= {}
|
||||
options[:procs] ||= []
|
||||
options[:procs] << lambda {|options, record| options[:builder].tag!("uploader-name", record.uploader_name)}
|
||||
super(options, &block)
|
||||
end
|
||||
end
|
||||
|
||||
include ConversionMethods
|
||||
include ValidationMethods
|
||||
include FileMethods
|
||||
@@ -376,6 +397,7 @@ class Upload < ActiveRecord::Base
|
||||
include StatusMethods
|
||||
include UploaderMethods
|
||||
extend SearchMethods
|
||||
include ApiMethods
|
||||
|
||||
def add_file_size_tags!(file_path)
|
||||
if file_size >= 10.megabytes
|
||||
@@ -383,6 +405,10 @@ class Upload < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def uploader_name
|
||||
User.id_to_name(uploader_id)
|
||||
end
|
||||
|
||||
def presenter
|
||||
@presenter ||= UploadPresenter.new(self)
|
||||
end
|
||||
|
||||
@@ -52,7 +52,29 @@ class WikiPage < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
module ApiMethods
|
||||
def serializable_hash(options = {})
|
||||
options ||= {}
|
||||
options[:except] ||= []
|
||||
options[:except] += hidden_attributes
|
||||
unless options[:builder]
|
||||
options[:methods] ||= []
|
||||
options[:methods] += [:creator_name]
|
||||
end
|
||||
hash = super(options)
|
||||
hash
|
||||
end
|
||||
|
||||
def to_xml(options = {}, &block)
|
||||
options ||= {}
|
||||
options[:procs] ||= []
|
||||
options[:procs] << lambda {|options, record| options[:builder].tag!("creator-name", record.creator_name)}
|
||||
super(options, &block)
|
||||
end
|
||||
end
|
||||
|
||||
extend SearchMethods
|
||||
include ApiMethods
|
||||
|
||||
def self.find_title_and_id(title)
|
||||
titled(title).select("title, id").first
|
||||
@@ -81,7 +103,7 @@ class WikiPage < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def creator_name
|
||||
User.id_to_name(user_id).tr("_", " ")
|
||||
User.id_to_name(creator_id).tr("_", " ")
|
||||
end
|
||||
|
||||
def category_name
|
||||
|
||||
@@ -12,17 +12,17 @@ every 1.day, :at => "1:00 am" do
|
||||
runner "Upload.delete_all(['created_at < ?', 1.day.ago])"
|
||||
end
|
||||
|
||||
every 1.day, :at => "2:00 am" do
|
||||
every 1.day, :at => "1:30 am" do
|
||||
runner "ModAction.delete_all(['created_at < ?', 3.days.ago])"
|
||||
end
|
||||
|
||||
every 1.day, :at => "3:00 am" do
|
||||
every 1.day, :at => "2:00 am" do
|
||||
command "cd /var/www/danbooru2/current ; script/donmai/backup_db"
|
||||
command "cd /var/www/danbooru2/current ; script/donmai/backup_db_to_s3"
|
||||
command "cd /var/www/danbooru2/current ; script/donmai/prune_backup_dbs"
|
||||
end
|
||||
|
||||
every 1.day, :at => "4:00 am" do
|
||||
every 1.day, :at => "3:00 am" do
|
||||
command "psql --set-statement-timeout=0 -hdbserver -c \"vacuum analyze verbose;\" danbooru2"
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user