Skip to content

Loading…

lost + duplication item in pagination with order #307

Closed
gmgp opened this Issue · 1 comment

2 participants

@gmgp

on Heroku if I use a order the pagination act strange

rails 3.2.11    
will_paginate (3.0.3)
class Event < ActiveRecord::Base
  self.per_page = 12
  ...
  scope :open, lambda{|date| where("giorno_inizio >= ?", date)}
  ...
end

If I try this is the situation

list = []; 
16.times{|i| Event.open(Date.today).page(i+1).map{|i| list << i.id}}
list.uniq.size #=> 190

list_ord = []; 
16.times{|i| Event.open(Date.today).order(:giorno_inizio).page(i+1).map{|i| list_ord << i.id}}
list.uniq.size #=> 179

list_p = {}
16.times{|i| list_p["page_#{i+1}"] = Event.inaugurati_dal(Date.today).page(i+1).map{|i| [i.id, i.giorno_inizio]}}
list_p 
#=>

  {"page_1"=>[[9072, Sun, 21 Apr 2013], [8763, Fri, 06 Sep 2013], [8853, Fri, 03 May 2013], [8854, Mon, 20 May 2013], [8855, Thu, 06 Jun 2013], [8971, Fri, 10 May 2013], [8972, Fri, 31 May 2013], [8978, Sun, 26 May 2013], [9074, Fri, 26 Apr 2013], [9088, Sat, 20 Apr 2013], [9157, Sun, 28 Apr 2013], [9158, Sun, 21 Apr 2013]], 
  "page_2"=>[[9160, Sat, 20 Apr 2013], [9161, Sun, 05 May 2013], [9142, Sat, 25 May 2013], [9143, Sat, 22 Jun 2013], [9144, Thu, 13 Jun 2013], [9145, Sat, 07 Sep 2013], [9146, Fri, 20 Sep 2013], [1668, Fri, 04 Oct 2013], [8553, Sun, 05 May 2013], [8554, Sun, 29 Sep 2013], [8597, Sat, 08 Jun 2013], [8601, Sat, 20 Apr 2013]], 
  "page_3"=>[[8695, Thu, 16 May 2013], [8697, Sat, 21 Sep 2013], [8698, Sat, 28 Sep 2013], [8827, Sun, 09 Jun 2013], [8900, Sat, 18 May 2013], [8976, Sat, 27 Apr 2013], [8977, Sat, 25 May 2013], [9012, Sat, 20 Apr 2013], [9025, Sat, 20 Apr 2013], [9031, Fri, 19 Apr 2013], [9032, Sat, 20 Apr 2013], [9034, Thu, 25 Apr 2013]], 
  "page_4"=>[[9079, Fri, 19 Apr 2013], [9080, Sun, 21 Apr 2013], [9125, Sat, 18 May 2013], [9115, Sat, 20 Apr 2013], [9119, Sat, 04 May 2013], [9120, Tue, 23 Jul 2013], [9121, Sat, 20 Apr 2013], [9139, Sun, 16 Jun 2013], [9169, Sun, 05 May 2013], [9170, Sun, 05 May 2013], [9172, Sun, 05 May 2013], [9173, Thu, 02 May 2013]], 
  "page_5"=>[[9174, Sun, 05 May 2013], [9175, Sun, 05 May 2013], [9215, Mon, 06 May 2013], [9217, Mon, 29 Apr 2013], [9228, Thu, 19 Sep 2013], [9167, Fri, 19 Apr 2013], [9230, Thu, 22 Aug 2013], [9138, Sat, 25 May 2013], [9154, Tue, 24 Dec 2013], [8436, Sat, 25 May 2013], [8696, Fri, 05 Jul 2013], [8682, Fri, 05 Jul 2013]], 
  "page_6"=>[[9211, Fri, 07 Jun 2013], [9206, Sat, 20 Apr 2013], [9162, Sat, 20 Apr 2013], [9196, Tue, 28 May 2013], [9197, Tue, 11 Jun 2013], [8929, Sat, 13 Jul 2013], [8066, Fri, 03 May 2013], [8067, Wed, 08 May 2013], [8068, Tue, 14 May 2013], [8147, Sat, 20 Apr 2013], [9092, Fri, 19 Apr 2013], [9093, Fri, 19 Apr 2013]], 
  "page_7"=>[[9094, Sat, 20 Apr 2013], [9095, Sun, 21 Apr 2013], [9096, Fri, 26 Apr 2013], [9070, Fri, 19 Apr 2013], [9159, Fri, 19 Apr 2013], [9208, Sat, 20 Apr 2013], [9041, Thu, 02 May 2013], [9043, Sun, 19 May 2013], [8211, Sun, 01 Sep 2013], [7490, Wed, 12 Jun 2013], [8254, Sun, 05 May 2013], [1771, Sun, 13 Oct 2013]], 
  "page_8"=>[[8928, Sun, 17 Nov 2013], [8759, Wed, 01 May 2013], [800, Sat, 06 Jul 2013], [8249, Sat, 27 Apr 2013], [8251, Sat, 27 Apr 2013], [8253, Sat, 11 May 2013], [682, Tue, 23 Jul 2013], [8683, Sun, 08 Sep 2013], [8951, Thu, 02 May 2013], [8953, Thu, 06 Jun 2013], [8954, Thu, 17 Oct 2013], [8955, Thu, 20 Jun 2013]], 
  "page_9"=>[[8956, Thu, 11 Jul 2013], [8957, Thu, 19 Sep 2013], [8958, Sun, 30 Jun 2013], [8959, Sat, 20 Jul 2013], [8960, Sat, 10 Aug 2013], [8961, Thu, 01 Aug 2013], [8962, Sun, 05 May 2013], [8963, Wed, 28 Aug 2013], [9013, Sat, 08 Jun 2013], [9011, Sun, 12 May 2013], [9124, Fri, 26 Apr 2013], [9185, Sat, 20 Apr 2013]], 
  "page_10"=>[[9186, Sat, 04 May 2013], [9187, Sun, 05 May 2013], [9188, Sun, 19 May 2013], [8256, Sat, 20 Apr 2013], [8257, Fri, 24 May 2013], [8210, Sun, 20 Oct 2013], [8775, Sun, 21 Apr 2013], [524, Sat, 20 Jul 2013], [9189, Sat, 04 May 2013], [9210, Sun, 12 May 2013], [9201, Sat, 04 May 2013], [9202, Sat, 11 May 2013]], 
  "page_11"=>[[9203, Sat, 18 May 2013], [9204, Sat, 25 May 2013], [9205, Sat, 01 Jun 2013], [9229, Sun, 09 Jun 2013], [9049, Sun, 26 May 2013], [9050, Fri, 12 Jul 2013], [9100, Thu, 25 Apr 2013], [9123, Sun, 28 Apr 2013], [9231, Wed, 01 May 2013], [8679, Thu, 25 Apr 2013], [8681, Sat, 25 May 2013], [8423, Fri, 10 May 2013]], 
  "page_12"=>[[8761, Sun, 20 Oct 2013], [8762, Fri, 20 Sep 2013], [6171, Sun, 28 Apr 2013], [9233, Fri, 17 May 2013], [9042, Sat, 25 May 2013], [8950, Wed, 01 May 2013], [9008, Sun, 21 Apr 2013], [9009, Sat, 20 Apr 2013], [9033, Sun, 05 May 2013], [9140, Sat, 22 Jun 2013], [9141, Sat, 31 Aug 2013], [9128, Sat, 04 May 2013]], 
  "page_13"=>[[9129, Sat, 01 Jun 2013], [9130, Sat, 06 Jul 2013], [9131, Sat, 03 Aug 2013], [9132, Sat, 07 Sep 2013], [9133, Sat, 05 Oct 2013], [9134, Sat, 02 Nov 2013], [9135, Sat, 07 Dec 2013], [9136, Sat, 04 Jan 2014], [9086, Fri, 19 Apr 2013], [9087, Sat, 20 Apr 2013], [9232, Wed, 01 May 2013], [9183, Fri, 19 Apr 2013]], 
  "page_14"=>[[9184, Sat, 20 Apr 2013], [9148, Thu, 27 Jun 2013], [9149, Sat, 24 Aug 2013], [9150, Sat, 08 Jun 2013], [9151, Fri, 20 Sep 2013], [9153, Wed, 23 Oct 2013], [7775, Fri, 19 Apr 2013], [7776, Fri, 10 May 2013], [257, Fri, 24 May 2013], [8888, Sun, 21 Apr 2013], [8889, Sun, 05 May 2013], [8890, Sun, 19 May 2013]], 
  "page_15"=>[[8891, Sun, 26 May 2013], [8295, Sat, 18 May 2013], [8629, Thu, 23 May 2013], [8631, Sat, 18 May 2013], [8657, Sat, 20 Apr 2013], [8658, Sun, 19 May 2013], [8659, Sun, 22 Sep 2013], [8838, Sat, 18 May 2013], [8927, Sun, 12 May 2013], [9044, Sun, 19 May 2013], [9045, Sat, 27 Apr 2013], [9046, Sat, 22 Jun 2013]], 
  "page_16"=>[[9047, Sat, 06 Jul 2013], [9048, Sun, 10 Nov 2013], [9164, Fri, 19 Apr 2013], [8424, Fri, 03 May 2013], [8430, Sun, 12 May 2013], [8598, Fri, 19 Apr 2013], [8830, Sun, 12 May 2013], [9199, Thu, 25 Apr 2013], [9218, Mon, 22 Apr 2013], [9039, Fri, 17 May 2013]]}

 list_p_o = {}; 
16.times{|i| list_p_o["page_#{i+1}"] = Event.open(Date.today).order(:giorno_inizio).page(i+1).map{|i| [i.id, i.giorno_inizio}}
list_p_o  

#=>
{
"page_1"=>[[9159, Fri, 19 Apr 2013], [7775, Fri, 19 Apr 2013], [9092, Fri, 19 Apr 2013], [9070, Fri, 19 Apr 2013], [9086, Fri, 19 Apr 2013], [9183, Fri, 19 Apr 2013], [9031, Fri, 19 Apr 2013], [9167, Fri, 19 Apr 2013], [9079, Fri, 19 Apr 2013], [9093, Fri, 19 Apr 2013], [8598, Fri, 19 Apr 2013], [9164, Fri, 19 Apr 2013]],
 "page_2"=>[[9025, Sat, 20 Apr 2013], [9121, Sat, 20 Apr 2013], [8601, Sat, 20 Apr 2013], [9160, Sat, 20 Apr 2013], [8147, Sat, 20 Apr 2013], [9206, Sat, 20 Apr 2013], [8256, Sat, 20 Apr 2013], [9162, Sat, 20 Apr 2013], [9094, Sat, 20 Apr 2013], [9012, Sat, 20 Apr 2013], [9088, Sat, 20 Apr 2013], [9208, Sat, 20 Apr 2013]],
 "page_3"=>[[9160, Sat, 20 Apr 2013], [9206, Sat, 20 Apr 2013], [9184, Sat, 20 Apr 2013], [9121, Sat, 20 Apr 2013], [9025, Sat, 20 Apr 2013], [9012, Sat, 20 Apr 2013], [8657, Sat, 20 Apr 2013], [9008, Sun, 21 Apr 2013], [9095, Sun, 21 Apr 2013], [9080, Sun, 21 Apr 2013], [9158, Sun, 21 Apr 2013], [8888, Sun, 21 Apr 2013]],
 "page_4"=>[[9080, Sun, 21 Apr 2013], [9072, Sun, 21 Apr 2013], [9218, Mon, 22 Apr 2013], [9199, Thu, 25 Apr 2013], [8679, Thu, 25 Apr 2013], [9034, Thu, 25 Apr 2013], [9100, Thu, 25 Apr 2013], [9096, Fri, 26 Apr 2013], [9124, Fri, 26 Apr 2013], [9074, Fri, 26 Apr 2013], [8976, Sat, 27 Apr 2013], [9045, Sat, 27 Apr 2013]],
 "page_5"=>[[8251, Sat, 27 Apr 2013], [8976, Sat, 27 Apr 2013], [9123, Sun, 28 Apr 2013], [6171, Sun, 28 Apr 2013], [9157, Sun, 28 Apr 2013], [9217, Mon, 29 Apr 2013], [9232, Wed, 01 May 2013], [8759, Wed, 01 May 2013], [9231, Wed, 01 May 2013], [8950, Wed, 01 May 2013], [8951, Thu, 02 May 2013], [9173, Thu, 02 May 2013]],
 "page_6"=>[[8951, Thu, 02 May 2013], [8853, Fri, 03 May 2013], [8424, Fri, 03 May 2013], [8066, Fri, 03 May 2013], [9189, Sat, 04 May 2013], [9201, Sat, 04 May 2013], [9119, Sat, 04 May 2013], [9128, Sat, 04 May 2013], [9186, Sat, 04 May 2013], [9161, Sun, 05 May 2013], [9175, Sun, 05 May 2013], [9174, Sun, 05 May 2013]],
 "page_7"=>[[9033, Sun, 05 May 2013], [9175, Sun, 05 May 2013], [9174, Sun, 05 May 2013], [9172, Sun, 05 May 2013], [9170, Sun, 05 May 2013], [9169, Sun, 05 May 2013], [8889, Sun, 05 May 2013], [8254, Sun, 05 May 2013], [8962, Sun, 05 May 2013], [9215, Mon, 06 May 2013], [8067, Wed, 08 May 2013], [8971, Fri, 10 May 2013]],
 "page_8"=>[[8971, Fri, 10 May 2013], [7776, Fri, 10 May 2013], [9202, Sat, 11 May 2013], [8253, Sat, 11 May 2013], [8927, Sun, 12 May 2013], [9011, Sun, 12 May 2013], [8830, Sun, 12 May 2013], [8430, Sun, 12 May 2013], [9210, Sun, 12 May 2013], [8068, Tue, 14 May 2013], [8695, Thu, 16 May 2013], [9233, Fri, 17 May 2013]],
 "page_9"=>[[9039, Fri, 17 May 2013], [8295, Sat, 18 May 2013], [8900, Sat, 18 May 2013], [9203, Sat, 18 May 2013], [9125, Sat, 18 May 2013], [8631, Sat, 18 May 2013], [8838, Sat, 18 May 2013], [9188, Sun, 19 May 2013], [9043, Sun, 19 May 2013], [9044, Sun, 19 May 2013], [8658, Sun, 19 May 2013], [8890, Sun, 19 May 2013]],
 "page_10"=>[[8854, Mon, 20 May 2013], [8629, Thu, 23 May 2013], [8257, Fri, 24 May 2013], [257, Fri, 24 May 2013], [9138, Sat, 25 May 2013], [8681, Sat, 25 May 2013], [9204, Sat, 25 May 2013], [8977, Sat, 25 May 2013], [9142, Sat, 25 May 2013], [8436, Sat, 25 May 2013], [9042, Sat, 25 May 2013], [8978, Sun, 26 May 2013]],
 "page_11"=>[[9049, Sun, 26 May 2013], [8891, Sun, 26 May 2013], [9196, Tue, 28 May 2013], [8972, Fri, 31 May 2013], [9205, Sat, 01 Jun 2013], [9129, Sat, 01 Jun 2013], [8953, Thu, 06 Jun 2013], [8855, Thu, 06 Jun 2013], [9211, Fri, 07 Jun 2013], [9150, Sat, 08 Jun 2013], [9013, Sat, 08 Jun 2013], [8597, Sat, 08 Jun 2013]],
 "page_12"=>[[8827, Sun, 09 Jun 2013], [9229, Sun, 09 Jun 2013], [9197, Tue, 11 Jun 2013], [7490, Wed, 12 Jun 2013], [9144, Thu, 13 Jun 2013], [9139, Sun, 16 Jun 2013], [8955, Thu, 20 Jun 2013], [9143, Sat, 22 Jun 2013], [9046, Sat, 22 Jun 2013], [9140, Sat, 22 Jun 2013], [9148, Thu, 27 Jun 2013], [8958, Sun, 30 Jun 2013]],
 "page_13"=>[[8696, Fri, 05 Jul 2013], [8682, Fri, 05 Jul 2013], [9130, Sat, 06 Jul 2013], [9047, Sat, 06 Jul 2013], [800, Sat, 06 Jul 2013], [8956, Thu, 11 Jul 2013], [9050, Fri, 12 Jul 2013], [8929, Sat, 13 Jul 2013], [8959, Sat, 20 Jul 2013], [524, Sat, 20 Jul 2013], [682, Tue, 23 Jul 2013], [9120, Tue, 23 Jul 2013]],
 "page_14"=>[[8961, Thu, 01 Aug 2013], [9131, Sat, 03 Aug 2013], [8960, Sat, 10 Aug 2013], [9230, Thu, 22 Aug 2013], [9149, Sat, 24 Aug 2013], [8963, Wed, 28 Aug 2013], [9141, Sat, 31 Aug 2013], [8211, Sun, 01 Sep 2013], [8763, Fri, 06 Sep 2013], [9145, Sat, 07 Sep 2013], [9132, Sat, 07 Sep 2013], [8683, Sun, 08 Sep 2013]],
 "page_15"=>[[8957, Thu, 19 Sep 2013], [9228, Thu, 19 Sep 2013], [9146, Fri, 20 Sep 2013], [9151, Fri, 20 Sep 2013], [8762, Fri, 20 Sep 2013], [8697, Sat, 21 Sep 2013], [8659, Sun, 22 Sep 2013], [8698, Sat, 28 Sep 2013], [8554, Sun, 29 Sep 2013], [1668, Fri, 04 Oct 2013], [9133, Sat, 05 Oct 2013], [1771, Sun, 13 Oct 2013]],
 "page_16"=>[[8954, Thu, 17 Oct 2013], [8761, Sun, 20 Oct 2013], [8210, Sun, 20 Oct 2013], [9153, Wed, 23 Oct 2013], [9134, Sat, 02 Nov 2013], [9048, Sun, 10 Nov 2013], [8928, Sun, 17 Nov 2013], [9135, Sat, 07 Dec 2013], [9154, Tue, 24 Dec 2013], [9136, Sat, 04 Jan 2014]]}

on checking

list_p["page_12"][7]  #=> [9009, Sat, 20 Apr 2013]  

in ordered hash is lost like other 10 but

list_p_o["page_2"][0] #=> [9025, Sat, 20 Apr 2013]
list_p_o["page_3"][4] #=> [9025, Sat, 20 Apr 2013]

Any idea?

@mislav
Owner

No idea what's going on. Probably something in your databasse. Let me know if strangeness still persists with will_paginate v3.0.5

@mislav mislav closed this
@mislav mislav added invalid unconfirmed and removed invalid labels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.