Skip to content

Conversation

JenySadadia
Copy link
Collaborator

@JenySadadia JenySadadia commented Nov 17, 2023

Fixes #390
Fixes #410

Enable support for querying boolean fields while getting objects from API such as nodes or models.
e.g. find all the active admin users using
http://API_SERVER/users?is_active=true&is_superuser=true

@gctucker gctucker self-assigned this Nov 17, 2023
@JenySadadia
Copy link
Collaborator Author

Tested OK on staging:

$ curl https://staging.kernelci.org:9000/latest/users?is_verified=true
{"items":[{"id":"62554673a68f9bac63a0ead2","email":"guillaume.tucker@collabora.com","is_active":true,"is_superuser":false,"is_verified":true,"username":"gtucker","groups":[]},{"id":"62f3ec222d0a223569d55be7","email":"kernelci-tsc@groups.io","is_active":true,"is_superuser":true,"is_verified":true,"username":"admin","groups":[{"id":"649190b01432ccfdb575a250","name":"admin"}]},{"id":"654b618eb5e6b3443a48e55b","email":"denys.f@collabora.com","is_active":true,"is_superuser":false,"is_verified":true,"username":"nuclearcat","groups":[]}],"total":3,"limit":50,"offset":0}

@JenySadadia JenySadadia requested a review from a team November 27, 2023 10:01
Copy link
Contributor

@gctucker gctucker left a comment

Choose a reason for hiding this comment

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

LGTM - some minor comments.

Jeny Sadadia added 2 commits November 30, 2023 17:50
Enable support for querying boolean fields while getting
objects from API such as nodes or models.
e.g. find all the active admin users using
`http://API_SERVER/users?is_active=true&is_superuser=true`

Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
Instead of using integer values 1 and 0 for `User` model
boolean fields, use `True` and `False` to enable querying
boolean fields in MongoDB as per the syntax.

Fixes: 310f3d6 ("migration: add migration for user documents")
Signed-off-by: Jeny Sadadia <jeny.sadadia@collabora.com>
@JenySadadia JenySadadia force-pushed the translate-bool-fields branch from 19c893d to 54008c5 Compare November 30, 2023 12:21
@gctucker
Copy link
Contributor

gctucker commented Dec 1, 2023

Thanks for the updates, LGTM now. I haven't tested it so not approving yet.

@nuclearcat
Copy link
Member

LGTM, tested by curl.
Merging, but as follow-up i guess we need to support that in cli as well, and i guess it will be tricky, because at moment:

./kci user find is_active=true
[]

@nuclearcat nuclearcat added this pull request to the merge queue Dec 1, 2023
Merged via the queue into kernelci:main with commit 06e8e13 Dec 1, 2023
@JenySadadia
Copy link
Collaborator Author

LGTM, tested by curl. Merging, but as follow-up i guess we need to support that in cli as well, and i guess it will be tricky, because at moment:

./kci user find is_active=true
[]

Works for me:

$ ./kci user find is_superuser=true
[{"id": "6526448e7d140ee220971a0e", "email": "admin@gmail.com", "is_active": true, "is_superuser": true, "is_verified": true, "username": "admin", "groups": [{"id": "648c07a70fccad400a122509", "name": "admin"}, {"id": "648ff894bd39930355ed16ad", "name": "kernelci"}]}]

@JenySadadia JenySadadia deleted the translate-bool-fields branch December 1, 2023 10:44
@nuclearcat
Copy link
Member

You are right, sorry for noise, kci was pointing to wrong instance, my mistake.

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.

Query attributes don't handle boolean values Enable find users with boolean query filters
3 participants