goat-community / goat

This is the home of Geo Open Accessibility Tool (GOAT)
GNU General Public License v3.0
89 stars 47 forks source link

Endpoints sorting by column and search for each column #1597

Closed EPajares closed 1 year ago

EPajares commented 1 year ago

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

cinaaaa commented 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?

EPajares commented 1 year ago

As discussed I think we have to do the endpoints first. They should do the following:

EPajares commented 1 year ago

@metemaddar we can discuss how we should change the endpoints

cinaaaa commented 1 year ago

@EPajares Yes, exactly

metemaddar commented 1 year ago

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

Summary

EPajares commented 1 year ago

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.

EPajares commented 1 year ago

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.

metemaddar commented 1 year ago

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.

metemaddar commented 1 year ago

@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:

metemaddar commented 1 year ago

Now implemented search by q=search_query and sort by sorting=-desc_field,field

metemaddar commented 1 year ago

@cinaaaa Search and Sorting is available for users endpoint.

metemaddar commented 1 year ago

Search and sort can be easily applied to other list endpoints as well.

metemaddar commented 1 year ago

@cinaaaa The ordering/search is now available for the following endpoints at branch: goat-community:feat/endpoints-search-ordering