Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix max results for for all data #85

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

flug
Copy link

@flug flug commented Sep 5, 2024

ft.search return 10 results by default

ft.search return 10 results by default
@flug
Copy link
Author

flug commented Sep 5, 2024

Either we do that or we make a constant that gives 10000 max results which avoids doing the count as you want @clementtalleu ?

@codecov-commenter
Copy link

codecov-commenter commented Sep 5, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 81.48148% with 5 lines in your changes missing coverage. Please review.

Project coverage is 70.77%. Comparing base (651e5a9) to head (370561b).

Files with missing lines Patch % Lines
src/Client/PredisClient.php 0.00% 3 Missing ⚠️
src/Client/RedisClient.php 0.00% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #85      +/-   ##
============================================
+ Coverage     70.65%   70.77%   +0.12%     
- Complexity      540      546       +6     
============================================
  Files            42       42              
  Lines          1213     1232      +19     
============================================
+ Hits            857      872      +15     
- Misses          356      360       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/Client/PredisClient.php Show resolved Hide resolved
src/Client/PredisClient.php Show resolved Hide resolved
src/Client/RedisClient.php Show resolved Hide resolved
{
if ($limit === null) {
$limit = $this->count([]);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add new line after the condition block

private function defineLimit(?int $limit = null)
{
if ($limit === null) {
$limit = $this->count([]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to know the total number of results if no limit is indicated?

it adds a call to redis in addition to FT.SEARCH

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's what I'm telling you, what we can do is make a constant since FT.SEARCH seems to return 10 results by default, so we can set a constant to 10000 so there are no more count calls, do you prefer that?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, I prefer to avoid useless redis call and put an hardcoded value.

Maybe we could add it directly in the attribute #[Entity] ? 10000 by default and configurable for users, what do you think ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from my point of view, I'm not sure it's the Entity attribute that should carry this, I'd say it's a value linked to the ft.search functional, I'd say that either we remove the nullable from the limit argument and set it to 10000 by default, or we define a constant that would be the value to avoid calls to the count method in the AbstractObjectRepository. Knowing that if you have more than 10000 results, which could happen in my case, you'll have to iterate on them automatically when you do a findAll or this kind of method, since you want to have everything.

What do you think?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but I think users should be able to change the default number.
I still have no idea of the best way to do it, if you have an idea I'd love to hear it, otherwise let's keep it constant.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use FT.AGGREGATE and then a FT.CURSOR cursor, but I'm not sure that's a good idea.

@flug flug force-pushed the fix/minimum-results branch from dacdc97 to 83a8c16 Compare September 6, 2024 09:06
@flug flug force-pushed the fix/minimum-results branch from 83a8c16 to af83571 Compare September 6, 2024 13:07
@@ -17,7 +17,7 @@ abstract class AbstractObjectRepository implements RepositoryInterface
public ?string $className = null;
protected ?RedisClientInterface $redisClient = null;
protected ?ConverterInterface $converter = null;

private const DEFAULT_SEARCH_LIMIT = 10000;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, add new line

@clementtalleu clementtalleu merged commit 1baad20 into clementtalleu:main Sep 10, 2024
2 checks passed
@clementtalleu
Copy link
Owner

thanks a lot @flug !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants