Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/concerns/json_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def forbidden_filters
# allow_create
# end
#
def allow_create(controller_attributes = nil)
def allow_create(controller_attributes = {})
hash = strong_attributes
.merge(strong_relationships)
.merge(controller_attributes)
Expand Down
2 changes: 1 addition & 1 deletion app/models/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ def ratio
sizes = original.split('.').first.gsub('@', '').split('x')
width = sizes.first.to_i
height = sizes.last.to_i
(width / height).to_f
width.to_f / height
end
end
10 changes: 5 additions & 5 deletions app/services/image_conversion_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def run
raise 'wrong class' unless @image.is_a? Image
raise 'already in progress' if @image.converting
raise 'missing original' if @image.original.nil?
raise 'missing ratio' if @image.ratio.nil?
raise 'missing ratio' if @image.ratio.nil? || @image.ratio.zero?
raise 'wrong format' unless %w[png jpg jpeg].include? @image.original_ext

path = @image.path
Expand Down Expand Up @@ -64,7 +64,6 @@ def run
end
to_create = wish_list - existing
to_delete = existing - wish_list - [original]

logger.info '------'
logger.info 'found on CDN:'
existing.each { |file| logger.info file }
Expand Down Expand Up @@ -190,7 +189,8 @@ def run
logger.info '------'

@image.update!(
conversion_error_log: "#{e.message} | #{e.class.name} | #{e.backtrace}"
conversion_error_log: "#{e.message} | #{e.class.name} | #{e.backtrace}",
converting: false
)

# TODO: notify Jan of fail
Expand All @@ -200,13 +200,13 @@ def run

def lock_image
logger.info '------'
logger.info 'Lock image'
logger.info 'lock image'
@image.update!(converting: true)
end

def unlock_image
logger.info '------'
logger.info 'Unlock image'
logger.info 'unlock image'
@image.update!(converting: false)
end

Expand Down
9 changes: 7 additions & 2 deletions wiki/development.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ bin/rails db:drop;
bin/rails db:create
bin/rails db:migrate

# Create backup of production database
# Sync production database down to development

scripts/backup.sh

# Serve Rails

bin/rails s
Expand All @@ -88,7 +93,7 @@ bin/rails c
bin/rails generate custom_scaffold products --version=v1 --scope=public
bin/rails generate custom_scaffold product_documents --version=v1 --scope=admin

# Seed database
# Seed database (outdated)

bin/rails db:seed
bin/rails db:seed:documents
Expand All @@ -98,7 +103,7 @@ bin/rails db:seed:products

bin/rails db:fixtures:load FIXTURES=articles

# Drop database and start over
# Drop database and start over (outdated)

bin/rails db:environment:set RAILS_ENV=development;
bin/rails db:drop;
Expand Down