update to rails 4.2.5.1, add debugging info for tracking slow queries
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -47,7 +47,6 @@ gem 'capistrano-rbenv'
|
|||||||
gem 'radix62', '~> 1.0.1'
|
gem 'radix62', '~> 1.0.1'
|
||||||
gem 'streamio-ffmpeg'
|
gem 'streamio-ffmpeg'
|
||||||
gem 'rubyzip', :require => "zip"
|
gem 'rubyzip', :require => "zip"
|
||||||
gem 'coinbase'
|
|
||||||
gem 'stripe'
|
gem 'stripe'
|
||||||
gem 'twitter'
|
gem 'twitter'
|
||||||
gem 'aws-sdk', '~> 2'
|
gem 'aws-sdk', '~> 2'
|
||||||
|
|||||||
84
Gemfile.lock
84
Gemfile.lock
@@ -14,36 +14,36 @@ GIT
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
actionmailer (4.2.3)
|
actionmailer (4.2.5.1)
|
||||||
actionpack (= 4.2.3)
|
actionpack (= 4.2.5.1)
|
||||||
actionview (= 4.2.3)
|
actionview (= 4.2.5.1)
|
||||||
activejob (= 4.2.3)
|
activejob (= 4.2.5.1)
|
||||||
mail (~> 2.5, >= 2.5.4)
|
mail (~> 2.5, >= 2.5.4)
|
||||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||||
actionpack (4.2.3)
|
actionpack (4.2.5.1)
|
||||||
actionview (= 4.2.3)
|
actionview (= 4.2.5.1)
|
||||||
activesupport (= 4.2.3)
|
activesupport (= 4.2.5.1)
|
||||||
rack (~> 1.6)
|
rack (~> 1.6)
|
||||||
rack-test (~> 0.6.2)
|
rack-test (~> 0.6.2)
|
||||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||||
actionview (4.2.3)
|
actionview (4.2.5.1)
|
||||||
activesupport (= 4.2.3)
|
activesupport (= 4.2.5.1)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
erubis (~> 2.7.0)
|
erubis (~> 2.7.0)
|
||||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||||
activejob (4.2.3)
|
activejob (4.2.5.1)
|
||||||
activesupport (= 4.2.3)
|
activesupport (= 4.2.5.1)
|
||||||
globalid (>= 0.3.0)
|
globalid (>= 0.3.0)
|
||||||
activemodel (4.2.3)
|
activemodel (4.2.5.1)
|
||||||
activesupport (= 4.2.3)
|
activesupport (= 4.2.5.1)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
activerecord (4.2.3)
|
activerecord (4.2.5.1)
|
||||||
activemodel (= 4.2.3)
|
activemodel (= 4.2.5.1)
|
||||||
activesupport (= 4.2.3)
|
activesupport (= 4.2.5.1)
|
||||||
arel (~> 6.0)
|
arel (~> 6.0)
|
||||||
activesupport (4.2.3)
|
activesupport (4.2.5.1)
|
||||||
i18n (~> 0.7)
|
i18n (~> 0.7)
|
||||||
json (~> 1.7, >= 1.7.7)
|
json (~> 1.7, >= 1.7.7)
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
@@ -64,7 +64,6 @@ GEM
|
|||||||
bcrypt (>= 3.1.3)
|
bcrypt (>= 3.1.3)
|
||||||
bcrypt-ruby (3.1.5-x64-mingw32)
|
bcrypt-ruby (3.1.5-x64-mingw32)
|
||||||
bcrypt (>= 3.1.3)
|
bcrypt (>= 3.1.3)
|
||||||
bigdecimal (1.2.7)
|
|
||||||
buftok (0.2.0)
|
buftok (0.2.0)
|
||||||
builder (3.2.2)
|
builder (3.2.2)
|
||||||
byebug (6.0.0)
|
byebug (6.0.0)
|
||||||
@@ -92,8 +91,6 @@ GEM
|
|||||||
coffee-script-source
|
coffee-script-source
|
||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.9.1.1)
|
coffee-script-source (1.9.1.1)
|
||||||
coinbase (4.0.7)
|
|
||||||
bigdecimal
|
|
||||||
colorize (0.7.7)
|
colorize (0.7.7)
|
||||||
crack (0.4.2)
|
crack (0.4.2)
|
||||||
safe_yaml (~> 1.0.0)
|
safe_yaml (~> 1.0.0)
|
||||||
@@ -151,9 +148,9 @@ GEM
|
|||||||
thread_safe (~> 0.3, >= 0.3.1)
|
thread_safe (~> 0.3, >= 0.3.1)
|
||||||
metaclass (0.0.4)
|
metaclass (0.0.4)
|
||||||
method_source (0.8.2)
|
method_source (0.8.2)
|
||||||
mime-types (2.6.1)
|
mime-types (2.99.1)
|
||||||
mini_portile (0.6.2)
|
mini_portile2 (2.0.0)
|
||||||
minitest (5.8.0)
|
minitest (5.8.4)
|
||||||
mocha (1.1.0)
|
mocha (1.1.0)
|
||||||
metaclass (~> 0.0.1)
|
metaclass (~> 0.0.1)
|
||||||
multi_json (1.11.2)
|
multi_json (1.11.2)
|
||||||
@@ -168,10 +165,10 @@ GEM
|
|||||||
net-ssh (2.9.2)
|
net-ssh (2.9.2)
|
||||||
netrc (0.10.3)
|
netrc (0.10.3)
|
||||||
newrelic_rpm (3.13.0.299)
|
newrelic_rpm (3.13.0.299)
|
||||||
nokogiri (1.6.6.2)
|
nokogiri (1.6.7.2)
|
||||||
mini_portile (~> 0.6.0)
|
mini_portile2 (~> 2.0.0.rc2)
|
||||||
nokogiri (1.6.6.2-x64-mingw32)
|
nokogiri (1.6.7.2-x64-mingw32)
|
||||||
mini_portile (~> 0.6.0)
|
mini_portile2 (~> 2.0.0.rc2)
|
||||||
nokogumbo (1.2.0)
|
nokogumbo (1.2.0)
|
||||||
nokogiri
|
nokogiri
|
||||||
ntlm-http (0.1.1)
|
ntlm-http (0.1.1)
|
||||||
@@ -192,16 +189,16 @@ GEM
|
|||||||
rack-test (0.6.3)
|
rack-test (0.6.3)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
radix62 (1.0.1)
|
radix62 (1.0.1)
|
||||||
rails (4.2.3)
|
rails (4.2.5.1)
|
||||||
actionmailer (= 4.2.3)
|
actionmailer (= 4.2.5.1)
|
||||||
actionpack (= 4.2.3)
|
actionpack (= 4.2.5.1)
|
||||||
actionview (= 4.2.3)
|
actionview (= 4.2.5.1)
|
||||||
activejob (= 4.2.3)
|
activejob (= 4.2.5.1)
|
||||||
activemodel (= 4.2.3)
|
activemodel (= 4.2.5.1)
|
||||||
activerecord (= 4.2.3)
|
activerecord (= 4.2.5.1)
|
||||||
activesupport (= 4.2.3)
|
activesupport (= 4.2.5.1)
|
||||||
bundler (>= 1.3.0, < 2.0)
|
bundler (>= 1.3.0, < 2.0)
|
||||||
railties (= 4.2.3)
|
railties (= 4.2.5.1)
|
||||||
sprockets-rails
|
sprockets-rails
|
||||||
rails-deprecated_sanitizer (1.0.3)
|
rails-deprecated_sanitizer (1.0.3)
|
||||||
activesupport (>= 4.2.0.alpha)
|
activesupport (>= 4.2.0.alpha)
|
||||||
@@ -209,15 +206,15 @@ GEM
|
|||||||
activesupport (>= 4.2.0.beta, < 5.0)
|
activesupport (>= 4.2.0.beta, < 5.0)
|
||||||
nokogiri (~> 1.6.0)
|
nokogiri (~> 1.6.0)
|
||||||
rails-deprecated_sanitizer (>= 1.0.1)
|
rails-deprecated_sanitizer (>= 1.0.1)
|
||||||
rails-html-sanitizer (1.0.2)
|
rails-html-sanitizer (1.0.3)
|
||||||
loofah (~> 2.0)
|
loofah (~> 2.0)
|
||||||
railties (4.2.3)
|
railties (4.2.5.1)
|
||||||
actionpack (= 4.2.3)
|
actionpack (= 4.2.5.1)
|
||||||
activesupport (= 4.2.3)
|
activesupport (= 4.2.5.1)
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (>= 0.18.1, < 2.0)
|
thor (>= 0.18.1, < 2.0)
|
||||||
raindrops (0.15.0)
|
raindrops (0.15.0)
|
||||||
rake (10.4.2)
|
rake (10.5.0)
|
||||||
ref (2.0.0)
|
ref (2.0.0)
|
||||||
responders (2.1.0)
|
responders (2.1.0)
|
||||||
railties (>= 4.2.0, < 5)
|
railties (>= 4.2.0, < 5)
|
||||||
@@ -265,7 +262,7 @@ GEM
|
|||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
rack (~> 1.0)
|
rack (~> 1.0)
|
||||||
tilt (~> 1.1, != 1.3.0)
|
tilt (~> 1.1, != 1.3.0)
|
||||||
sprockets-rails (2.3.2)
|
sprockets-rails (2.3.3)
|
||||||
actionpack (>= 3.0)
|
actionpack (>= 3.0)
|
||||||
activesupport (>= 3.0)
|
activesupport (>= 3.0)
|
||||||
sprockets (>= 2.8, < 4.0)
|
sprockets (>= 2.8, < 4.0)
|
||||||
@@ -337,7 +334,6 @@ DEPENDENCIES
|
|||||||
capistrano-rbenv
|
capistrano-rbenv
|
||||||
capistrano3-unicorn
|
capistrano3-unicorn
|
||||||
coffee-rails
|
coffee-rails
|
||||||
coinbase
|
|
||||||
daemons
|
daemons
|
||||||
dalli
|
dalli
|
||||||
delayed_job
|
delayed_job
|
||||||
@@ -386,4 +382,4 @@ DEPENDENCIES
|
|||||||
whenever
|
whenever
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.10.0
|
1.11.2
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ module Moderator
|
|||||||
|
|
||||||
CurrentUser.without_safe_mode do
|
CurrentUser.without_safe_mode do
|
||||||
CurrentUser.scoped(updater, updater_ip_addr) do
|
CurrentUser.scoped(updater, updater_ip_addr) do
|
||||||
::Post.tag_match(antecedent).find_each do |post|
|
::Post.tag_match(antecedent).where("true /* Moderator::TagBatchChange#perform */").find_each do |post|
|
||||||
tags = (post.tag_array - normalized_antecedent + normalized_consequent).join(" ")
|
tags = (post.tag_array - normalized_antecedent + normalized_consequent).join(" ")
|
||||||
post.update_attributes(:tag_string => tags)
|
post.update_attributes(:tag_string => tags)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ module PostSets
|
|||||||
|
|
||||||
def posts
|
def posts
|
||||||
@posts ||= begin
|
@posts ||= begin
|
||||||
query = ::Post.tag_match(@artist.name).limit(10)
|
query = ::Post.tag_match(@artist.name).where("true /* PostSets::Artist#posts */").limit(10)
|
||||||
query.each # hack to force rails to eager load
|
query.each # hack to force rails to eager load
|
||||||
query
|
query
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ module PostSets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def has_deleted?
|
def has_deleted?
|
||||||
tag_string !~ /status/ && ::Post.tag_match("#{tag_string} status:deleted").exists?
|
tag_string !~ /status/ && ::Post.tag_match("#{tag_string} status:deleted").where("true /* PostSets::Post#has_deleted */").exists?
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_explicit?
|
def has_explicit?
|
||||||
@@ -127,9 +127,9 @@ module PostSets
|
|||||||
if random
|
if random
|
||||||
temp = get_random_posts()
|
temp = get_random_posts()
|
||||||
elsif raw
|
elsif raw
|
||||||
temp = ::Post.raw_tag_match(tag_string).order("posts.id DESC").paginate(page, :count => post_count, :limit => per_page)
|
temp = ::Post.raw_tag_match(tag_string).order("posts.id DESC").where("true /* PostSets::Post#posts:1 */").paginate(page, :count => post_count, :limit => per_page)
|
||||||
else
|
else
|
||||||
temp = ::Post.tag_match(tag_string, read_only).paginate(page, :count => post_count, :limit => per_page)
|
temp = ::Post.tag_match(tag_string, read_only).where("true /* PostSets::Post#posts:2 */").paginate(page, :count => post_count, :limit => per_page)
|
||||||
end
|
end
|
||||||
temp.each # hack to force rails to eager load
|
temp.each # hack to force rails to eager load
|
||||||
temp
|
temp
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ class RelatedTagCalculator
|
|||||||
candidates = convert_hash_to_array(counts, 100)
|
candidates = convert_hash_to_array(counts, 100)
|
||||||
similar_counts = Hash.new {|h, k| h[k] = 0}
|
similar_counts = Hash.new {|h, k| h[k] = 0}
|
||||||
CurrentUser.without_safe_mode do
|
CurrentUser.without_safe_mode do
|
||||||
Post.with_timeout(5_000) do
|
PostReadOnly.with_timeout(5_000) do
|
||||||
candidates.each do |ctag, _|
|
candidates.each do |ctag, _|
|
||||||
acount = Post.tag_match("#{tag} #{ctag}").count
|
acount = PostReadOnly.tag_match("#{tag} #{ctag}").count
|
||||||
ctag_record = Tag.find_by_name(ctag)
|
ctag_record = Tag.find_by_name(ctag)
|
||||||
div = Math.sqrt(tag_record.post_count * ctag_record.post_count)
|
div = Math.sqrt(tag_record.post_count * ctag_record.post_count)
|
||||||
if div != 0
|
if div != 0
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class UserDeletion
|
|||||||
def self.remove_favorites_for(user_id)
|
def self.remove_favorites_for(user_id)
|
||||||
user = User.find(user_id)
|
user = User.find(user_id)
|
||||||
Post.without_timeout do
|
Post.without_timeout do
|
||||||
Post.raw_tag_match("fav:#{user_id}").find_each do |post|
|
Post.raw_tag_match("fav:#{user_id}").where("true /* UserDeletion.remove_favorites_for */").find_each do |post|
|
||||||
Favorite.remove(post, user)
|
Favorite.remove(post, user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ class Artist < ActiveRecord::Base
|
|||||||
if params[:name]
|
if params[:name]
|
||||||
artist.name = params[:name]
|
artist.name = params[:name]
|
||||||
post = CurrentUser.without_safe_mode do
|
post = CurrentUser.without_safe_mode do
|
||||||
Post.tag_match("source:http #{artist.name}").first
|
Post.tag_match("source:http #{artist.name}").where("true /* Artist.new_with_defaults */").first
|
||||||
end
|
end
|
||||||
unless post.nil? || post.source.blank?
|
unless post.nil? || post.source.blank?
|
||||||
artist.url_string = post.source
|
artist.url_string = post.source
|
||||||
@@ -271,7 +271,7 @@ class Artist < ActiveRecord::Base
|
|||||||
ti.destroy if ti
|
ti.destroy if ti
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Post.tag_match(name).each do |post|
|
Post.tag_match(name).where("true /* Artist.unban */").each do |post|
|
||||||
post.unban!
|
post.unban!
|
||||||
fixed_tags = post.tag_string.sub(/(?:\A| )banned_artist(?:\Z| )/, " ").strip
|
fixed_tags = post.tag_string.sub(/(?:\A| )banned_artist(?:\Z| )/, " ").strip
|
||||||
post.update_attributes(:tag_string => fixed_tags)
|
post.update_attributes(:tag_string => fixed_tags)
|
||||||
@@ -289,7 +289,7 @@ class Artist < ActiveRecord::Base
|
|||||||
Post.transaction do
|
Post.transaction do
|
||||||
CurrentUser.without_safe_mode do
|
CurrentUser.without_safe_mode do
|
||||||
begin
|
begin
|
||||||
Post.tag_match(name).each do |post|
|
Post.tag_match(name).where("true /* Artist.ban */").each do |post|
|
||||||
post.ban!
|
post.ban!
|
||||||
end
|
end
|
||||||
rescue Post::SearchError
|
rescue Post::SearchError
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class Tag < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def real_post_count
|
def real_post_count
|
||||||
@real_post_count ||= Post.raw_tag_match(name).count
|
@real_post_count ||= Post.raw_tag_match(name).where("true /* Tag#real_post_count */").count
|
||||||
end
|
end
|
||||||
|
|
||||||
def fix_post_count
|
def fix_post_count
|
||||||
@@ -131,7 +131,7 @@ class Tag < ActiveRecord::Base
|
|||||||
|
|
||||||
def update_category_post_counts
|
def update_category_post_counts
|
||||||
Post.with_timeout(30_000, nil) do
|
Post.with_timeout(30_000, nil) do
|
||||||
Post.raw_tag_match(name).find_each do |post|
|
Post.raw_tag_match(name).where("true /* Tag#update_category_post_counts */").find_each do |post|
|
||||||
post.reload
|
post.reload
|
||||||
post.set_tag_counts
|
post.set_tag_counts
|
||||||
Post.where(:id => post.id).update_all(:tag_count => post.tag_count, :tag_count_general => post.tag_count_general, :tag_count_artist => post.tag_count_artist, :tag_count_copyright => post.tag_count_copyright, :tag_count_character => post.tag_count_character)
|
Post.where(:id => post.id).update_all(:tag_count => post.tag_count, :tag_count_general => post.tag_count_general, :tag_count_artist => post.tag_count_artist, :tag_count_copyright => post.tag_count_copyright, :tag_count_character => post.tag_count_character)
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ class TagImplication < ActiveRecord::Base
|
|||||||
|
|
||||||
def update_posts
|
def update_posts
|
||||||
Post.without_timeout do
|
Post.without_timeout do
|
||||||
Post.raw_tag_match(antecedent_name).find_each do |post|
|
Post.raw_tag_match(antecedent_name).where("true /* TagImplication#update_posts */").find_each do |post|
|
||||||
fixed_tags = "#{post.tag_string} #{descendant_names}".strip
|
fixed_tags = "#{post.tag_string} #{descendant_names}".strip
|
||||||
CurrentUser.scoped(creator, creator_ip_addr) do
|
CurrentUser.scoped(creator, creator_ip_addr) do
|
||||||
post.update_attributes(
|
post.update_attributes(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class AddIndexToArtistGroupName < ActiveRecord::Migration
|
class AddIndexToArtistGroupName < ActiveRecord::Migration
|
||||||
def change
|
def change
|
||||||
add_index :artists, :group_name
|
# add_index :artists, :group_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
16
db/seeds.rb
16
db/seeds.rb
@@ -1,4 +1,5 @@
|
|||||||
require 'set'
|
require 'set'
|
||||||
|
require 'timecop'
|
||||||
|
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
Delayed::Worker.delay_jobs = false
|
Delayed::Worker.delay_jobs = false
|
||||||
@@ -38,11 +39,14 @@ end
|
|||||||
|
|
||||||
if User.count == 0
|
if User.count == 0
|
||||||
puts "Creating users"
|
puts "Creating users"
|
||||||
user = User.create(
|
|
||||||
:name => "admin",
|
Timecop.travel(1.month.ago) do
|
||||||
:password => "password1",
|
user = User.create(
|
||||||
:password_confirmation => "password1"
|
:name => "admin",
|
||||||
)
|
:password => "password1",
|
||||||
|
:password_confirmation => "password1"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
0.upto(10) do |i|
|
0.upto(10) do |i|
|
||||||
User.create(
|
User.create(
|
||||||
@@ -69,7 +73,7 @@ if Upload.count == 0
|
|||||||
url = "http://ipsumimage.appspot.com/#{width}x#{height}"
|
url = "http://ipsumimage.appspot.com/#{width}x#{height}"
|
||||||
tags = rand_sentence(12).scan(/[a-z]+/).join(" ")
|
tags = rand_sentence(12).scan(/[a-z]+/).join(" ")
|
||||||
|
|
||||||
Upload.create(:source => url, :content_type => "image/gif", :rating => "q", :tag_string => tags, :server => Socket.gethostname)
|
Upload.create!(:source => url, :content_type => "image/gif", :rating => "q", :tag_string => tags, :server => Socket.gethostname)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
puts "Skipping uploads"
|
puts "Skipping uploads"
|
||||||
|
|||||||
1185
db/structure.sql
1185
db/structure.sql
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user