kidpollo / tanker

IndexTank Integration with your fav ORM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pagination total_results not counting correct

marcusg opened this issue · comments

Hello guys,
i don't know if i make something wrong. here is my problem:

Tour.all.count

89
t = Tour.search_tank "deutsch*"
t.count
8
t.total_entries
87

The 8 is the real (correct) resultset (all tours with "deutsch*" in the content). But why is total_entries 87?
As far as i understand this, will_paginate uses the total_entries to calculate the paginate links ( < 1 2 3 > ).
So i get 9 paginate links for only 8 results (with 10 per page). I don't know, maybe it's a paginate bug, but i use will_paginate at other places without tanker without problems. Any help is appreciated, thanks!

It seems there are other people also having problems with pagination. Thanks for the info it gives me a better ide on where the bug is I just hope I get the time soon to work on this. If you feel like taking a dive it would be greatly appreciated

I just merged some changes from a pull request done by @adrnai which do some changes to the instatiation logic can you please test your code by using the code from master

gem 'tanker', :git => 'git://github.com/kidpollo/tanker.git'

Hi

I double checked this. I added a test to my integration suite to verify, all seems working.

It does feel very weird. My test is pretty basic may be there is something else going on. If you execute the raw query tanker generates what do you get back.

my test looks like this

describe 'An imaginary store' do
before(:all) do
Tanker::Utilities.clear_index('tanker_integration_tests')
100.times do ; Product.create(:name => 'crapoola', :href => "crappy", :tags => ['crappy']) ; end
Product.tanker_reindex
end

describe 'pagination' do
it 'should dilplay total results correctly' do
results = Product.search_tank('crapoola')
results.total_entries.should == 100
end
end
end

Try debugging the library

look for line in tanker.rb and throw a debugger in there

results = index.search(query, options)

BTW I released a new version of the gem with minor changes to pagination. I dont expect this could fix the issue but you might want to upgrade anyway.

@kidpollo, thanks! i will try and say if i got it running...

@kidpollo, I cleared all indexes and created new ones but the problem still exists. I'll try to find a solution, i hope i'm able to do it because you gem is awesome, i don't want to miss it :)

i tried it again and it seems to work! (some minutes ago i had a problem with per_page option) but with a clean project it's working very nice! thank you @kidpollo and @adrnai :)