Skip to content
This repository has been archived by the owner on Nov 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #8 from sue445/use_file_image
Browse files Browse the repository at this point in the history
fill_user_response: Use file image instead of db
  • Loading branch information
sue445 committed Nov 25, 2023
2 parents 4d25cf8 + a9afca4 commit 1573bea
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions ruby/app.rb
Expand Up @@ -192,13 +192,22 @@ def fill_reaction_response(tx, reaction_model)
def fill_user_response(tx, user_model)
theme_model = tx.xquery('SELECT * FROM themes WHERE user_id = ?', user_model.fetch(:id)).first

icon_model = tx.xquery('SELECT image FROM icons WHERE user_id = ?', user_model.fetch(:id)).first
image =
if icon_model
icon_model.fetch(:image)
# icon_model = tx.xquery('SELECT image FROM icons WHERE user_id = ?', user_model.fetch(:id)).first
# image =
# if icon_model
# icon_model.fetch(:image)
# else
# File.binread(FALLBACK_IMAGE)
# end

image_file =
if File.exist?("#{ICONS_DIR}/#{user_model.fetch(:name)}.jpg")
"#{ICONS_DIR}/#{user_model.fetch(:name)}.jpg"
else
File.binread(FALLBACK_IMAGE)
FALLBACK_IMAGE
end
image = File.binread(image_file)

icon_hash = Digest::SHA256.hexdigest(image)

{
Expand Down

0 comments on commit 1573bea

Please sign in to comment.