FA submission pages no longer have gender field

This commit is contained in:
Dylan Knutson
2025-06-18 15:53:53 +00:00
parent 7d0d94d761
commit 94533b6e45
7 changed files with 1176 additions and 9 deletions

View File

@@ -12,11 +12,10 @@ module Domain::ModelHelper
partial: String,
as: Symbol,
expires_in: ActiveSupport::Duration,
cache_key: T.untyped,
).returns(T.nilable(String))
end
def render_for_model(model, partial, as:, expires_in: 1.hour, cache_key: nil)
cache_key ||= [model, policy(model), partial]
def render_for_model(model, partial, as:, expires_in: 1.hour)
cache_key = [model, policy(model), partial].compact
Rails
.cache
.fetch(cache_key, expires_in:) do

View File

@@ -249,7 +249,7 @@ class Domain::Fa::Parser::SubmissionParserHelper < Domain::Fa::Parser::Base
end
end
sig { returns(String) }
sig { returns(T.nilable(String)) }
def gender
@gender ||=
case @page_version

View File

@@ -3,7 +3,10 @@ class Domain::PostFile < ReduxApplicationRecord
include AttrJsonRecordAliases
self.table_name = "domain_post_files"
belongs_to :post, foreign_key: :post_id, class_name: "::Domain::Post"
belongs_to :post,
foreign_key: :post_id,
class_name: "::Domain::Post",
touch: true
belongs_to :log_entry, class_name: "::HttpLogEntry", optional: true
belongs_to :blob,
class_name: "::BlobFile",

View File

@@ -1,5 +1,4 @@
<% return unless policy(post).view_scan_metadata? %>
<% %>
<div class="flex flex-row gap-4 w-full mt-2">
<div class="grow text-sm text-slate-500">
<i class="fa-solid fa-magnifying-glass mr-1"></i>

View File

@@ -676,6 +676,30 @@ describe Domain::Fa::Parser::Page do
end
end
it "works with new submission page format without gender field" do
parser =
get_parser_at(
Rails.root.join(
"test/fixtures/files/domain/fa/parser/redux/submission_48178881_no_gender_fields.html",
),
)
assert_page_type parser, :probably_submission?
sub = parser.submission
assert_equal "Artwork (Digital)", sub.category
assert_equal "Unspecified / Any", sub.species
assert_equal "Animal related (non-anthro)", sub.theme
assert_equal 128, sub.num_favorites
assert_equal 3, sub.num_comments
assert_equal 1706, sub.num_views
assert_equal Time
.zone
.parse("Jul 20, 2022 04:34 PM PST")
.change(zone: "UTC"),
sub.posted_date
assert_nil sub.gender
assert_equal :adult, sub.rating
end
def get_parser(file, require_logged_in: true)
path = File.join("domain/fa/parser/redux", file)
get_parser_at(path, require_logged_in:)

View File

@@ -1,3 +0,0 @@
# typed: strict
describe Domain::Fa::SqliteExporter do
end

File diff suppressed because it is too large Load Diff