This commit is contained in:
BoHung Chiu 2021-05-18 10:33:40 +08:00
parent b1088b75b3
commit 84ac920327
1 changed files with 3 additions and 0 deletions

View File

@ -55,6 +55,7 @@ class GalleriesController < ApplicationController
albums_no_order = album_tp.desc(:created_at).where(:order.in=>[-1,nil]).page(nil).per(all_count)[0...(page_data_count - albums_with_order.count)]
end
else
albums_with_order = []
start_index = (page_data_count - (with_order_count % page_data_count) + page_data_count*(page_no - 1 - with_order_total_pages))
albums_no_order = album_tp.desc(:created_at).where(:order.in=>[-1,nil]).page(nil).per(all_count)[start_index...(start_index+page_data_count)].to_a
end
@ -132,6 +133,7 @@ class GalleriesController < ApplicationController
page_no = (params[:page_no] || 1).to_i
if page_no < with_order_total_pages
albums_no_order = []
albums_with_order = albums_with_order[(page_no-1)*page_data_count...page_no*page_data_count]
elsif page_no == with_order_total_pages
if albums_with_order.count == page_data_count
albums_no_order = []
@ -139,6 +141,7 @@ class GalleriesController < ApplicationController
albums_no_order = album_tp.desc(:created_at).where(:order.in=>[-1,nil]).page(nil).per(all_count)[0...(page_data_count - albums_with_order.count)]
end
else
albums_with_order = []
start_index = (page_data_count - (with_order_count % page_data_count) + page_data_count*(page_no - 1 - with_order_total_pages))
albums_no_order = album_tp.desc(:created_at).where(:order.in=>[-1,nil]).page(nil).per(all_count)[start_index...(start_index+page_data_count)].to_a
end