SonataAdminBundle icon indicating copy to clipboard operation
SonataAdminBundle copied to clipboard

:bug: Fix label & method countResults to display good things with simple pager

Open elyanory opened this issue 1 year ago • 2 comments

Subject

Using SimplePager renders wrong statement on batch actions. For example: selecting 50 elements (on a table containing >1000 elements) the batch action checkbox "all_elements" would result in "all elements (51)".

Now with this PR, the display will change. A second basic query will be used to count the total number of results. Using the example above, this would give: "all elements (1000)".

Closes #8164.

Changelog

### Added
- `SimplePager::getTotalResults()` This method actually calculates the number of lines.

### Changed
- `SimplePager::countResults()` The "countResults" method now returns the true total number of lines ;
- `SimplePager::init()` The "init" method also calculates the total number of lines.

### Deprecated

### Removed

### Fixed

### Security

elyanory avatar May 15 '24 09:05 elyanory

But doesn't this make the simple pager super slow on huge datasets? I thought the whole reason to use the simple pager is because the count of the normal pager would take too long for certain entities?

zyberspace avatar May 15 '24 12:05 zyberspace

But doesn't this make the simple pager super slow on huge datasets? I thought the whole reason to use the simple pager is because the count of the normal pager would take too long for certain entities?

This is exactly the purpose of the SimplePager. You lost every benefit with such implementation.

You're right, I'm going to lean more towards the idea of displaying something like this: "25+". I thought that adding a simple query to get the total number of results would be interesting 😉

elyanory avatar May 17 '24 10:05 elyanory

https://github.com/sonata-project/SonataAdminBundle/pull/8205 strategy should be preferred

VincentLanglet avatar Nov 14 '24 19:11 VincentLanglet