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

Update Utopia\Database\Database->count() to ignore non-filter queries #192

Closed
Tracked by #190
stnguyen90 opened this issue Sep 22, 2022 · 0 comments · Fixed by #189
Closed
Tracked by #190

Update Utopia\Database\Database->count() to ignore non-filter queries #192

stnguyen90 opened this issue Sep 22, 2022 · 0 comments · Fixed by #189

Comments

@stnguyen90
Copy link
Contributor

stnguyen90 commented Sep 22, 2022

In several places in Appwrite, we have to do:

        $filterQueries = Query::groupByType($queries)['filters'];

        $response->dynamic(new Document([
            'users' => $dbForProject->find('users', $queries),
            'total' => $dbForProject->count('users', $filterQueries, APP_LIMIT_COUNT),
        ]), Response::MODEL_USER_LIST);

It would be much cleaner to have Utopia\Database\Database->count() grab only the filters so that the code can be simplified to:

-        $filterQueries = Query::groupByType($queries)['filters'];

        $response->dynamic(new Document([
            'users' => $dbForProject->find('users', $queries),
-            'total' => $dbForProject->count('users', $filterQueries, APP_LIMIT_COUNT),
+            'total' => $dbForProject->count('users', $queries, APP_LIMIT_COUNT),
        ]), Response::MODEL_USER_LIST);
@stnguyen90 stnguyen90 linked a pull request Sep 26, 2022 that will close this issue
1 task
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 a pull request may close this issue.

1 participant