fix timout error
This commit is contained in:
parent
76bf583da5
commit
81bdeb379e
|
@ -60,10 +60,19 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
def rotate_images
|
def rotate_images
|
||||||
begin
|
begin
|
||||||
image_ids = params['image_ids'].split(',')
|
image_ids = params['image_ids'].split(',')
|
||||||
images = AlbumImage.find(image_ids)
|
count = image_ids.count
|
||||||
count = images.length
|
|
||||||
rot_ang = params[:rotate_angle].to_i
|
rot_ang = params[:rotate_angle].to_i
|
||||||
images.each_with_index do |image,index|
|
variable = AlbumVariable.first
|
||||||
|
if variable.nil?
|
||||||
|
variable = AlbumVariable.new
|
||||||
|
end
|
||||||
|
variable.finish = false
|
||||||
|
variable.save!
|
||||||
|
Thread.new do
|
||||||
|
variable = AlbumVariable.first
|
||||||
|
image_ids.each_with_index do |image_id,index|
|
||||||
|
image = AlbumImage.find(image_id) rescue nil
|
||||||
|
next if image.nil?
|
||||||
if !(image.album_crops.first.nil?)
|
if !(image.album_crops.first.nil?)
|
||||||
w_and_h = image.file.get_w_and_h
|
w_and_h = image.file.get_w_and_h
|
||||||
cords = image.album_crops.map{|v| [[v.crop_x.to_f,v.crop_y.to_f],
|
cords = image.album_crops.map{|v| [[v.crop_x.to_f,v.crop_y.to_f],
|
||||||
|
@ -94,16 +103,6 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
end
|
end
|
||||||
image.album_crops.first.update_attributes(crop_x: all_x.min,crop_y: all_y.min,crop_w: all_x.max - all_x.min,crop_h: all_y.max - all_y.min)
|
image.album_crops.first.update_attributes(crop_x: all_x.min,crop_y: all_y.min,crop_w: all_x.max - all_x.min,crop_h: all_y.max - all_y.min)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
variable = AlbumVariable.first
|
|
||||||
if variable.nil?
|
|
||||||
variable = AlbumVariable.new
|
|
||||||
end
|
|
||||||
variable.finish = false
|
|
||||||
variable.save!
|
|
||||||
Thread.new do
|
|
||||||
variable = AlbumVariable.first
|
|
||||||
images.each_with_index do |image,index|
|
|
||||||
variable.progress_percent = (index*100.0/count).floor.to_s+'%'
|
variable.progress_percent = (index*100.0/count).floor.to_s+'%'
|
||||||
image.file.rotate_ang(rot_ang)
|
image.file.rotate_ang(rot_ang)
|
||||||
all_version = image.file.versions.map{|k,v| k}
|
all_version = image.file.versions.map{|k,v| k}
|
||||||
|
@ -132,22 +131,13 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
|
|
||||||
def save_crop
|
def save_crop
|
||||||
begin
|
begin
|
||||||
images = AlbumImage.all.select{|value| params[:id].include? value.id.to_s}
|
images = AlbumImage.where(:id.in => Array(params[:id]))
|
||||||
id = images.first.album_id.to_s
|
|
||||||
x = params['x']
|
x = params['x']
|
||||||
y = params['y']
|
y = params['y']
|
||||||
w = params['w']
|
w = params['w']
|
||||||
h = params['h']
|
h = params['h']
|
||||||
cords = x.zip(y,w,h)
|
cords = x.zip(y,w,h)
|
||||||
count = cords.length
|
count = cords.length
|
||||||
images.each_with_index do |image,index|
|
|
||||||
cord = cords[index]
|
|
||||||
if image.album_crops.first.nil?
|
|
||||||
image.album_crops.create(crop_x: cord[0],crop_y: cord[1],crop_w: cord[2],crop_h: cord[3])
|
|
||||||
else
|
|
||||||
image.album_crops.first.update_attributes(crop_x: cord[0],crop_y: cord[1],crop_w: cord[2],crop_h: cord[3])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
variable = AlbumVariable.first
|
variable = AlbumVariable.first
|
||||||
if variable.nil?
|
if variable.nil?
|
||||||
variable = AlbumVariable.new
|
variable = AlbumVariable.new
|
||||||
|
@ -156,8 +146,16 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
variable.save!
|
variable.save!
|
||||||
Thread.new do
|
Thread.new do
|
||||||
variable = AlbumVariable.first
|
variable = AlbumVariable.first
|
||||||
images.each_with_index do |image,index|
|
image_ids= images.pluck(:id)
|
||||||
variable.progress_percent = (index*100.0/count).floor.to_s+'%'
|
image_ids.each_with_index do |image_id,index|
|
||||||
|
image = AlbumImage.find(image_id)
|
||||||
|
cord = cords[index]
|
||||||
|
if image.album_crops.first.nil?
|
||||||
|
image.album_crops.create(crop_x: cord[0],crop_y: cord[1],crop_w: cord[2],crop_h: cord[3])
|
||||||
|
else
|
||||||
|
image.album_crops.first.update_attributes(crop_x: cord[0],crop_y: cord[1],crop_w: cord[2],crop_h: cord[3])
|
||||||
|
end
|
||||||
|
variable.progress_percent = (index*100.0/count).floor.to_s+'%'
|
||||||
all_version = image.file.versions.map{|k,v| k}
|
all_version = image.file.versions.map{|k,v| k}
|
||||||
begin
|
begin
|
||||||
#org_fname = image.file.path
|
#org_fname = image.file.path
|
||||||
|
@ -201,7 +199,7 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
variable.finish = false
|
variable.finish = false
|
||||||
variable.save!
|
variable.save!
|
||||||
choice_ids = params['album_id'].split(',')
|
choice_ids = params['album_id'].split(',')
|
||||||
albums = Album.all.select { |value| (choice_ids.include? value.id.to_s)}
|
albums = Album.where(:id.in => choice_ids)
|
||||||
if !(params['use_default']=='true')
|
if !(params['use_default']=='true')
|
||||||
color = params['color_choice'].to_s.empty? ? 'transparent' : params['color_choice']
|
color = params['color_choice'].to_s.empty? ? 'transparent' : params['color_choice']
|
||||||
albums.each do |album|
|
albums.each do |album|
|
||||||
|
@ -212,14 +210,15 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
count = 0
|
count = albums.reduce(0){|x,i| i.album_images.count+x}
|
||||||
albums.each{|album| count+=album.album_images.count }
|
|
||||||
Thread.new do
|
Thread.new do
|
||||||
i = 0
|
i = 0
|
||||||
album_ids = albums.map{|v| v.id}.clone
|
album_ids = albums.pluck(:id)
|
||||||
album_ids.each do |album_id|
|
album_ids.each do |album_id|
|
||||||
album = Album.find(album_id) rescue Album.new()
|
album = Album.find(album_id) rescue Album.new()
|
||||||
album.album_images.each do |image|
|
album_image_ids = album.album_images.pluck(:id)
|
||||||
|
album_image_ids.each do |image_id|
|
||||||
|
image = AlbumImage.find(image_id)
|
||||||
error = nil
|
error = nil
|
||||||
all_version = image.file.versions.map{|k,v| k}
|
all_version = image.file.versions.map{|k,v| k}
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Reference in New Issue