more e621 user fav migration tweaks
This commit is contained in:
@@ -64,48 +64,19 @@ namespace :e621 do
|
||||
|
||||
desc "Show statistics about e621 favs"
|
||||
task fav_stats: :environment do
|
||||
puts "counting total cached..."
|
||||
total_cached =
|
||||
ReduxApplicationRecord.connection.execute(<<~SQL).first["total"]
|
||||
select SUM((json_attributes->>'num_other_favs_cached')::int) as total
|
||||
from domain_e621_users
|
||||
SQL
|
||||
total_have = Domain::E621::Fav.count
|
||||
|
||||
puts "counting total have..."
|
||||
total_have = Domain::UserPostFav.for_post_type(Domain::Post::E621Post).count
|
||||
|
||||
helper = Class.new.extend(ActionView::Helpers::NumberHelper)
|
||||
puts "total cached: #{helper.number_with_delimiter(total_cached)}"
|
||||
puts "total have: #{helper.number_with_delimiter(total_have)}"
|
||||
puts "percent cached: #{((total_have.to_f / total_cached.to_f) * 100).round(1)}%"
|
||||
end
|
||||
|
||||
desc "debug sql"
|
||||
task debug_sql: :environment do
|
||||
# Domain::Post::E621Post.where(e621_id: 5350363)
|
||||
# puts Domain::Post::E621Post.where(e621_id: 5_350_363).explain.inspect
|
||||
# puts Domain::Post::FaPost.where(fa_id: 52_801_830).explain.inspect
|
||||
# puts Domain::Fa::Post.where(fa_id: 52_801_830).explain.inspect
|
||||
# puts Domain::Post::FaPost
|
||||
# .select(:fa_id)
|
||||
# .where(fa_id: 52_801_830)
|
||||
# .explain
|
||||
# .inspect
|
||||
|
||||
query = Domain::E621::Post.joins(domain_posts: :e621_id)
|
||||
# "LEFT JOIN domain_posts ON domain_e621_posts.e621_id =
|
||||
# (domain_posts.json_attributes->>'e621_id')::integer
|
||||
# AND domain_posts.type = 'Domain::Post::E621Post'",
|
||||
# ).where("domain_posts.id IS NULL")
|
||||
|
||||
puts query.explain.inspect
|
||||
|
||||
# puts Domain::Fa::Post
|
||||
# .joins(
|
||||
# "
|
||||
# LEFT JOIN domain_posts ON domain_fa_posts.fa_id =
|
||||
# (domain_posts.json_attributes->>'fa_id')::integer
|
||||
# ",
|
||||
# )
|
||||
# .where(domain_posts: { id: nil, type: "Domain::Post::FaPost" })
|
||||
# .explain
|
||||
# .inspect
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user