mymizu / mymizu-web

Web platform for mymizu
https://map.mymizu.co
Apache License 2.0
13 stars 20 forks source link

Add feature to filter types of refill spot #13

Open lawriecate opened 2 years ago

lawriecate commented 2 years ago

Depends on https://github.com/mymizu/mymizu-web/issues/9 Display filtering options so that users can narrow down selection

image

How to achieve with API:

be-anna commented 2 years ago

Please check notion link for more details: https://mymizu.notion.site/Filtering-the-map-b30ce6adce1b4e4b83abee146d5047ca

lawriecate commented 2 years ago
image

In the design there are some example tags next to the filter icons Then if you click the filter icon there is a modal with the full range of sorting/filtering options displayed

image

- Please do not implement the sort filter yet, or how to refill

be-anna commented 1 year ago

Design: https://www.figma.com/file/HfT3GwZlpR6q9RScMNdF5D/mymizu-Web-App?node-id=728%3A12175

sjfricke commented 1 year ago

Hackathon 2023 Design Idea Dump:

The search should be done in the Database (Eloquent ORM)

The search result is a logcial expression

From the above mock-up design

image

The boolean expression becomes

( ("cold" or "filtered") and ("help yourself") and ("wi-fi" or "Rest space") )

Using the id above this becomes

[[3, 1], [9], [4, 10]]

a query would need to look like

$users = DB::table('tags')->where([
    ['3','1'],   // cold
    ['1','1'],   // filtered
])->orWhere([
    ['9', '1'],  // help yourself
])->orWhere([
    ['4', '1'],  // wi-fi
    ['10', '1'], // Rest space
])->get();

The backend could generate this dynamically with something like the following

app.get("/tags/search2", async (req, res) => {
    const filters = req.filters; // [[3, 1], [9], [4, 10]]
    query = DB::table('tags');

    for (filter : filters) {
        search_query = [];
        for (f : filter) {
            search_query.append([f, "1"]);
        }
        if (filter == filters.start()) {
            query->where(search_query);
        } else {
            query->orWhere(search_query);
        }
    }
    res.send(query->get());
});

Problems with current API

The above proposal has 2 issues with the current /taps/search API

  1. tags is "Comma seperated tag IDs", this doesn't allow a way to express the needed expression above
  2. categories (type of location), could be another filter category. In theory, categories and tags both serve the same purpose, but the fact they are different fields is something to consider with a design

This means a potential new /tags/search2 API endpoint might be needed

How buttons are added to filter list

When the /tags API is called and gives a list of both id and names (adjusted for language), it can then generate the buttons.

{
    "id": 1,
    "name": "Facilities",
    "tags": [
        {
            "id": 4,
            "name": "Wifi"
        },
        {
            "id": 5,
            "name": "Wheelchair-Accessible"
        }
    ]
},

becomes a row of buttons where when clicked, the id is known dynamically

Finding if the place is open

The biggest issue of finding if a place is open is the fact time zones are different where you look.

If 2 locations in Japan and Austrilla are open at 10:00am, but it is 9:00am in Japan but 11:00am in Austrilla at some moment, then only the Austrilla location is open, regardless where the client is searching from (confirmed this is what Google Maps does as well)

This can be resolved into a boolean expression as

(day == current_day_of_week) and (current_time > opening_time) and (current_time < closing_time)