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