unused image finder
This commit is contained in:
@ -5,7 +5,7 @@ module Merged
|
||||
before_action :set_image, only: %i[ update destroy show scale crop copy ]
|
||||
|
||||
def index
|
||||
@images = Image.all
|
||||
@images = get_images
|
||||
@image_data = @images.collect{|i|
|
||||
data = i.attributes.dup
|
||||
data[:url] = view_context.asset_path(i.asset_name)
|
||||
@ -65,6 +65,18 @@ module Merged
|
||||
|
||||
private
|
||||
|
||||
def get_images
|
||||
images = Image.all
|
||||
puts "Images #{images.length}"
|
||||
return images unless params[:unused]
|
||||
hash = images.collect{|i| [i.id , i ] }.to_h
|
||||
puts "Images1 #{hash.length}"
|
||||
Section.all.each{ |s| hash.delete(s.image&.id)}
|
||||
puts "Images2 #{hash.length}"
|
||||
Card.all.each{ |s| hash.delete(s.image&.id)}
|
||||
puts "Images3 #{hash.length}"
|
||||
hash.values
|
||||
end
|
||||
def set_image
|
||||
@image = Image.find(params[:id] || params[:image_id])
|
||||
end
|
||||
|
Reference in New Issue
Block a user