Closed EPajares closed 1 year ago
@EPajares I'm a bit confused that where exactly you need the search bar, may we have a scheduled meeting for it?
As discussed I think we have to do the endpoints first. They should do the following:
@metemaddar we can discuss how we should change the endpoints
@EPajares Yes, exactly
Just thinking loud.
I think it's better to add the ordering
and like
options to the CRUD base, so that it will apply to all endpoints. I'm also thinking about adding a new class to accept q
and ordering
so that we can add it to all endpoints to accept query filters.
But I should be aware of queries to not conflict. Of course when we create an abstract class for them, we can change the name anytime. Also it would be good to take a look at some best practices. One is here and is like this:
/employees?lastName=Smith&age=30
We get:
[
{
"firstName": "John",
"lastName": "Smith",
"age": 30
}
]
Also it suggests to use page as one of standard parameters. And also need limit parameter. In CRUD Base we have the skip and limit for get_multi and I think it's enough for endpoints. Because we mostly should use get multi for listing items: https://github.com/goat-community/goat/blob/1fc0bdd8ce4c34412305ab8b0de94a770312f150/app/api/src/crud/base.py#L68-L70
For sorting:
http://example.com/articles?sort=+author,-datepublished
like
parameter to get searched.
[ ] We need sort implementation so that:
-
sign to order descget_multi
CRUD method.Hi Mohammad thanks for summing up the thoughts. All makes sense from my point of view. I believe we should add this additional parameters to be passed to the endpoints as optional parameters. So we could still use the endpoint without them. Other then this maybe you could test the implementation of it.
One thing that we might have to discuss if we still want to have a search by all columns. Currently, this is implemented in the client.
One thing that we might have to discuss if we still want to have a search by all columns. Currently, this is implemented in the client.
There are two scenarios to implement sort/search. Implement at front or back. If we decide to implement search at frontend, then sorting can get implemented at front using the searchable/sort-able tables. Because to implement search, we need to fetch all rows at front first.
@EPajares
In Django we have an option to provide search_fields. So whenever you apply a search it will search through the provided fields.
This has some advantages like:
It has some cons like:
Now implemented search by q=search_query
and sort by sorting=-desc_field,field
@cinaaaa Search and Sorting is available for users endpoint.
Search and sort can be easily applied to other list endpoints as well.
@cinaaaa The ordering/search is now available for the following endpoints at branch: goat-community:feat/endpoints-search-ordering
Goal of this issue
Currently, the search function only works for one column. As I have seen for users, it is the e-mail address, this sometimes makes it a bit unflexible. It would be great to have a search field for each column. This could eventually open when the user clicks on the column.
Furthermore, it would be good to sort alphabetically the table based on the values in a column.
Resources
Deliverables
New functionality sorting by column and search bar for each column.
Branch to derive
Dev