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

Not working 'search' query param with GET /api/jobs endpoint. #4385

Closed
2 tasks done
k1won opened this issue Feb 25, 2022 · 2 comments · Fixed by #4319
Closed
2 tasks done

Not working 'search' query param with GET /api/jobs endpoint. #4385

k1won opened this issue Feb 25, 2022 · 2 comments · Fixed by #4319

Comments

@k1won
Copy link
Contributor

k1won commented Feb 25, 2022

My actions before raising this issue

Expected Behaviour

  • When executing the GET method for the /api/jobs endpoint with the 'search' query param, expect to receive only the job instance corresponding to the search result.
    (It is specified in the api document to support the 'search' parameter)

Current Behaviour

  • When executing the GET method for the /api/jobs endpoint with the 'search' query param, all queryset results are returned.
  • This is because the 'search_fields' attribute does not exist in the JobViewSet class. (For test, I added the following code to the JobViewSet class and I found it works as expected)

search_fields = ('assignee__username', 'stage', 'state')

  • However, I do not conclude that it is a bug that search_fields is not declared in the JobViewSet class.
    This is because when checking 'Jobs' page in chrome web browser rather than REST API client (like Postman), stage, state, and assignee filter exist instead of search field, and I think this may be the design or implementation intention.
  • If my guess is correct, I think that 'search' should be excluded from the parameter list in the api document for GET /api/jobs.

Possible Solution

  • Excluding 'search' from the parameter list of GET /api/jobs in the api document.
    (This is possible by adding the code below to @extended_schema_view(list) of the JobViewSet class)
parameters=[
    OpenApiParameter('search', exclude=True)
],
  • Or add 'search_fields' attribute to JobViewSet class so that search query param works.

Steps to Reproduce (for bugs)

  1. Send http GET request using api client like below
    (http://localhost:7000/api/jobs?org=test&search=new)

Context

Your Environment

  • Git hash commit (git log -1): 01eaf36
  • Docker version docker version (e.g. Docker 17.0.05):
  • Are you using Docker Swarm or Kubernetes?
  • Operating System and version (e.g. Linux, Windows, MacOS): Ubuntu 18.04
  • Code example or link to GitHub repo or gist to reproduce problem:
  • Other diagnostic information / logs:
    Logs from `cvat` container

Next steps

You may join our Gitter channel for community support.

@nmanovic
Copy link
Contributor

@k1won , Thanks for the report. Could you please look at #4319? Will it close the issue?

@k1won
Copy link
Contributor Author

k1won commented Feb 25, 2022

@k1won , Thanks for the report. Could you please look at #4319? Will it close the issue?

@nmanovic , If #4319 is applied, only the search fields explicitly declared in the viewset class will be displayed in the api document by the SearchFilter class right?
If my understanding is correct, I think this issue(#4385) will be resolved.
I will test again after applying #4319.
Thanks for the information.

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.

2 participants