To avoid timeouts caused by excessive data
This commit is contained in:
parent
f335afb861
commit
df13ec28e2
|
|
@ -21,34 +21,46 @@ class Admin::ImagesController < OrbitAdminController
|
||||||
@images = @album.album_images.asc(:order)
|
@images = @album.album_images.asc(:order)
|
||||||
end
|
end
|
||||||
|
|
||||||
def changeorder
|
def changeorder
|
||||||
type = params[:type]
|
type = params[:type]
|
||||||
if type == "imgholder"
|
if type == "imgholder"
|
||||||
album = Album.find(params[:album_id]) rescue nil
|
album = Album.find(params[:album_id]) rescue nil
|
||||||
images = params[:imageids]
|
images = params[:imageids]
|
||||||
images.each_with_index.reverse_each do |image, i|
|
operations = []
|
||||||
img = AlbumImage.find(image) rescue nil
|
images.each_with_index.reverse_each do |image, i|
|
||||||
if !img.nil?
|
next if image.blank?
|
||||||
img.order = i
|
oid = begin; BSON::ObjectId(image); rescue; nil; end
|
||||||
img.save
|
next if oid.nil?
|
||||||
end
|
operations << {
|
||||||
end
|
update_one: {
|
||||||
if album
|
filter: { _id: oid },
|
||||||
album.update(:min_order=>-1)
|
update: { "$set" => { order: i } }
|
||||||
end
|
}
|
||||||
elsif type == "orbit_gallery"
|
}
|
||||||
albums = params[:imageids]
|
end
|
||||||
albums.each_with_index.reverse_each do |albumid, i|
|
AlbumImage.collection.bulk_write(operations) if operations.any?
|
||||||
album = Album.find(albumid) rescue nil
|
if album
|
||||||
if !album.nil?
|
album.update(:min_order=>-1)
|
||||||
album.order = i
|
end
|
||||||
album.save
|
elsif type == "orbit_gallery"
|
||||||
end
|
albums = params[:imageids]
|
||||||
end
|
operations = []
|
||||||
AlbumSetting.update_all(:min_order=>-1)
|
albums.each_with_index.reverse_each do |albumid, i|
|
||||||
end
|
next if albumid.blank?
|
||||||
render :json => {"success" => true}.to_json
|
oid = begin; BSON::ObjectId(albumid); rescue; nil; end
|
||||||
end
|
next if oid.nil?
|
||||||
|
operations << {
|
||||||
|
update_one: {
|
||||||
|
filter: { _id: oid },
|
||||||
|
update: { "$set" => { order: i } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
Album.collection.bulk_write(operations) if operations.any?
|
||||||
|
AlbumSetting.update_all(:min_order=>-1)
|
||||||
|
end
|
||||||
|
render :json => {"success" => true}.to_json
|
||||||
|
end
|
||||||
|
|
||||||
def delete_photos
|
def delete_photos
|
||||||
images = params['images']
|
images = params['images']
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue