From 84ac920327438ae92a77060b264365fcbb6b52da Mon Sep 17 00:00:00 2001 From: Bohung Date: Tue, 18 May 2021 10:33:40 +0800 Subject: [PATCH] Fix bug. --- app/controllers/galleries_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 682511f..271c0ff 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -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