Skip to content

Commit

Permalink
Item10596: remove the use of cursor->count() as its not returning wha…
Browse files Browse the repository at this point in the history
…t it should, and instead rely on the long_count

git-svn-id: http://svn.foswiki.org/trunk/MongoDBPlugin@11302 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Apr 5, 2011
1 parent 0134bc3 commit 17acb06
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions lib/Foswiki/Plugins/MongoDBPlugin/DB.pm
Expand Up @@ -79,20 +79,20 @@ my $db = $self->_getDatabase( $database );
$cursor = $cursor->fields({_web=>1, _topic=>1});
}

my $real_count = $cursor->count;
## my $real_count = $cursor->count;

if (($cursor->count == 0) and $cursor->has_next()) {
##if (($cursor->count == 0) and $cursor->has_next()) {
#fake it
$real_count = $long_count->{n};
$cursor->{real_count} = $real_count;
}

use Data::Dumper;
print STDERR "found "
. $cursor->count
. " (long_count = ".Dumper($long_count).") "
. " _BUT_ has_next is "
. ( $cursor->has_next() ? 'true' : 'false' ) . "\n" if DEBUG;
## $real_count = $long_count->{n};
$cursor->{real_count} = $long_count->{n};
##}

##use Data::Dumper;
## print STDERR "found "
## . $cursor->count
## . " (long_count = ".Dumper($long_count).") "
## . " _BUT_ has_next is "
## . ( $cursor->has_next() ? 'true' : 'false' ) . "\n" if DEBUG;

#more debugging
#print STDERR "get_collection(system.profile)".Dumper($db->get_collection("system.profile")->find->all)."\n";
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Search/MongoDBInfoCache.pm
Expand Up @@ -44,7 +44,7 @@ sub numberOfTopics {
return $this->{cachedCount} if (defined($this->{cachedCount}));
#count(1) takes into account the skip and limit settings
#TODO: make sure that this is what we want..
my $count = $this->{_cursor}->count(1);
my $count = 0;#$this->{_cursor}->count(1);
#TODO: find out if th
if (($count == 0) and $this->{_cursor}->has_next()) {
print STDERR "ERROR: cursor count == $count (real_count = ".$this->{_cursor}->{real_count}."), but cursor->has_next is true\n" if DEBUG;
Expand Down

0 comments on commit 17acb06

Please sign in to comment.