more fingerprint fixes
This commit is contained in:
@@ -238,9 +238,20 @@ class Domain::PostsController < DomainController
|
||||
sig { params(fingerprint_value: String).returns(ActiveRecord::Relation) }
|
||||
def find_similar_fingerprints(fingerprint_value)
|
||||
# Use the model's similar_to_fingerprint method directly
|
||||
Domain::PostFile::BitFingerprint.order_by_fingerprint_distance(
|
||||
fingerprint_value,
|
||||
).limit(10)
|
||||
|
||||
subquery = <<~SQL
|
||||
(
|
||||
select distinct on (post_file_id) *, (fingerprint_value <~> '#{ActiveRecord::Base.connection.quote_string(fingerprint_value)}') as distance
|
||||
from #{Domain::PostFile::BitFingerprint.table_name}
|
||||
order by post_file_id, distance asc
|
||||
) subquery
|
||||
SQL
|
||||
|
||||
Domain::PostFile::BitFingerprint
|
||||
.select("*")
|
||||
.from(subquery)
|
||||
.order("distance ASC")
|
||||
.limit(10)
|
||||
end
|
||||
|
||||
sig { override.returns(DomainController::DomainParamConfig) }
|
||||
|
||||
@@ -7,10 +7,11 @@ class Domain::PostFileThumbnailJob < Scraper::JobBase
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
sig { override.params(args: T::Hash[Symbol, T.untyped]).void }
|
||||
sig { override.params(args: T::Hash[Symbol, T.untyped]).returns(T.untyped) }
|
||||
def perform(args)
|
||||
post_file = T.cast(args[:post_file], Domain::PostFile)
|
||||
Domain::PostFile::Thumbnail.create_for_post_file!(post_file)
|
||||
Domain::PostFile::BitFingerprint.create_for_post_file!(post_file)
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -86,7 +86,7 @@ module Domain::StaticFileJobHelper
|
||||
ensure
|
||||
post_file.save! if post_file
|
||||
if should_enqueue_thumbnail_job
|
||||
defer_job(Domain::PostFileThumbnailJob, { post_file: })
|
||||
# defer_job(Domain::PostFileThumbnailJob, { post_file: })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
<% @post_file_fingerprints.each do |post_file_fingerprint| %>
|
||||
<% post_file = post_file_fingerprint.post_file %>
|
||||
<% post = post_file.post %>
|
||||
<% similarity_percentage = calculate_similarity_percentage(post_file_fingerprint.hash_value, @uploaded_hash_value) %>
|
||||
<div class="flex flex-col h-fit rounded-md border border-gray-300 bg-white shadow hover:shadow-md transition-shadow duration-300 overflow-hidden w-full sm:w-[calc(50%-0.75rem)] md:w-[calc(33.333%-0.75rem)] lg:w-[calc(25%-0.75rem)]">
|
||||
<div class="flex justify-between items-center border-b border-gray-200 p-2 bg-gray-50">
|
||||
<% similarity_percentage = calculate_similarity_percentage(post_file_fingerprint.fingerprint_value, @uploaded_hash_value) %>
|
||||
<div class="flex flex-col h-fit rounded-md border border-gray-300 bg-white shadow hover:shadow-md transition-shadow duration-300 overflow-hidden">
|
||||
<div class="flex justify-between items-center border-b border-gray-200 p-2 bg-gray-50 gap-2">
|
||||
<div class="flex items-center">
|
||||
<%= render "domain/posts/inline_postable_domain_link", post: post %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user