kaminari types, move views around
This commit is contained in:
53
Rakefile
53
Rakefile
@@ -178,3 +178,56 @@ task infer_last_submission_log_entries: :environment do
|
||||
puts parts.join(" ")
|
||||
end
|
||||
end
|
||||
|
||||
task fix_fa_post_files: :environment do
|
||||
file_ids = ENV["file_ids"]&.split(",") || raise("need 'file_ids'")
|
||||
Domain::Fa::Post
|
||||
.where(file_id: file_ids)
|
||||
.find_each { |post| post.fix_file_by_uri! }
|
||||
end
|
||||
|
||||
task fix_fa_post_files_by_csv: :environment do
|
||||
require "csv"
|
||||
|
||||
csv_file = ENV["csv_file"] || raise("need 'csv_file'")
|
||||
CSV
|
||||
.open(csv_file, headers: true)
|
||||
.each do |row|
|
||||
id = row["id"].to_i
|
||||
post = Domain::Fa::Post.find(id)
|
||||
post.fix_file_by_uri!
|
||||
end
|
||||
end
|
||||
|
||||
task fix_buggy_fa_posts: :environment do
|
||||
post_fa_ids = %w[7704069 7704068 6432347 6432346].map(&:to_i)
|
||||
|
||||
require "uri"
|
||||
|
||||
post_fa_ids.each do |fa_id|
|
||||
post = Domain::Fa::Post.find_by(fa_id: fa_id)
|
||||
next unless post&.file
|
||||
post_file_url_str = Addressable::URI.parse(post.file_url_str).to_s
|
||||
file_url_str = Addressable::URI.parse(CGI.unescape(post.file.uri.to_s)).to_s
|
||||
hle = post.guess_last_submission_page
|
||||
|
||||
parser = Domain::Fa::Parser::Page.new(hle.response.contents)
|
||||
if parser.submission_not_found?
|
||||
post.file = nil
|
||||
post.save!
|
||||
puts "submission not found"
|
||||
else
|
||||
submission = parser.submission
|
||||
full_res_img = Addressable::URI.parse(submission.full_res_img)
|
||||
full_res_img.scheme = "https" if full_res_img.scheme.blank?
|
||||
matches = full_res_img.to_s == post.file_url_str
|
||||
end
|
||||
|
||||
# if post_file_url_str != file_url_str
|
||||
# post.file = nil
|
||||
# post.save!
|
||||
# puts "url mismatch: #{post_file_url_str} != #{file_url_str}"
|
||||
# end
|
||||
# binding.pry
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user