Skip to content

Commit

Permalink
more fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Aug 26, 2024
1 parent bf0a85d commit 0d5f109
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/models/concerns/alegre_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def is_video?
def is_audio?
self.type == "audio"
end

def is_uploaded_media?
self.is_image? || self.is_audio? || self.is_video?
end
end

module AlegreV2
Expand Down Expand Up @@ -170,7 +174,7 @@ def content_hash(project_media, field)
return content_hash_for_value(project_media.media.url)
elsif project_media.is_a?(TemporaryProjectMedia)
return Rails.cache.read("url_sha:#{project_media.url}")
elsif !project_media.is_text?
elsif project_media.is_uploaded_media?
return project_media.media.file.filename.split(".").first
else
return content_hash_for_value(project_media.send(field).to_s)
Expand Down Expand Up @@ -313,6 +317,10 @@ def delete(project_media, field=nil, params={})
delete_package(project_media, field, params),
project_media
)
rescue StandardError => e
error = Error.new(e)
Rails.logger.error("[AutoTagger Bot] Exception for event `#{body['event']}`: #{error.class} - #{error.message}")
CheckSentry.notify(error, bot: "alegre", project_media: project_media, params: params, field: field)
end

def get_per_model_threshold(project_media, threshold)
Expand Down
4 changes: 4 additions & 0 deletions app/models/concerns/project_media_getters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def is_image?
self.is_uploaded_image?
end

def is_uploaded_media?
self.is_image? || self.is_audio? || self.is_video?
end

def is_text?
self.is_claim? || self.is_link?
end
Expand Down

0 comments on commit 0d5f109

Please sign in to comment.