tweak to post scan enqueue logic
This commit is contained in:
2
Rakefile
2
Rakefile
@@ -231,7 +231,7 @@ task enqueue_fa_posts_missing_files: %i[environment set_logger_stdout] do
|
||||
.where
|
||||
.missing(:file)
|
||||
.find_each(order: :desc) do |post|
|
||||
Domain::Fa::Job::ScanPostJob.perform_later(post:)
|
||||
Domain::Fa::Job::ScanPostJob.perform_now(post:)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ class Domain::Fa::Job::Base < Scraper::JobBase
|
||||
all_posts << post
|
||||
new_posts << post if post.new_record?
|
||||
|
||||
if post.new_record? || !post.state_ok? || post.scanned_at.blank? ||
|
||||
if post.new_record? || !post.state_ok? || post.file.blank? ||
|
||||
post.file&.state_terminal_error?
|
||||
post.state_ok!
|
||||
posts_to_save << post
|
||||
|
||||
@@ -37,19 +37,6 @@ class Domain::Post < ReduxApplicationRecord
|
||||
super
|
||||
end
|
||||
|
||||
sig { override.returns(T.nilable(ActiveSupport::TimeWithZone)) }
|
||||
def posted_at
|
||||
pa = super
|
||||
return pa if pa
|
||||
begin
|
||||
contents = guess_last_submission_log_entry&.response&.contents
|
||||
if contents
|
||||
parser = Domain::Fa::Parser::Page.new(contents)
|
||||
parser.submission.posted_date if parser.probably_submission?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
attr_json :last_submission_log_entry_id, :integer
|
||||
belongs_to :last_submission_log_entry,
|
||||
class_name: "::HttpLogEntry",
|
||||
|
||||
@@ -92,9 +92,12 @@ class Domain::Post::FaPost < Domain::Post
|
||||
|
||||
sig { override.returns(T.nilable(HttpLogEntry)) }
|
||||
def guess_last_submission_log_entry
|
||||
HttpLogEntry.find_all_by_uri(
|
||||
[
|
||||
"https://www.furaffinity.net/view/#{self.fa_id}",
|
||||
).first
|
||||
"https://www.furaffinity.net/view/#{self.fa_id}/",
|
||||
].lazy
|
||||
.map { |uri_str| HttpLogEntry.find_by_uri_host_path(uri_str) }
|
||||
.find(&:present?)
|
||||
end
|
||||
|
||||
sig { override.returns(T.nilable(String)) }
|
||||
@@ -147,4 +150,17 @@ class Domain::Post::FaPost < Domain::Post
|
||||
post.first_seen_entry = first_seen_log_entry
|
||||
end
|
||||
end
|
||||
|
||||
sig { override.returns(T.nilable(ActiveSupport::TimeWithZone)) }
|
||||
def posted_at
|
||||
pa = super
|
||||
return pa if pa
|
||||
begin
|
||||
contents = guess_last_submission_log_entry&.response&.contents
|
||||
if contents
|
||||
parser = Domain::Fa::Parser::Page.new(contents)
|
||||
parser.submission.posted_date if parser.probably_submission?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
<%= link_to post.title_for_view,
|
||||
post.external_url_for_view.to_s,
|
||||
class: "text-blue-600 hover:underline",
|
||||
target: "_blank" %>
|
||||
target: "_blank",
|
||||
rel: "noopener noreferrer" %>
|
||||
</span>
|
||||
<i class="fa-solid fa-arrow-up-right-from-square text-slate-400"></i>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user