Pensano-dev / aura-mobile-app

5 stars 0 forks source link

feat: BE - Add cafe opening time filtering to getFilteredCafes database queries #75

Open pablisch opened 4 months ago

pablisch commented 4 months ago

READ ME: This is an interesting but involved and tricky ticket which will require making data structure decisions and using this to add to an already complex database request. It may also break almost all existing project tests.

Description: Currently, the getFilteredCafes controller function for the /api/v1.0/cafes/selected endpoint makes an aggregated query using location and relevant facilities. What is missing in this query is only returning cafes that are currently open. The task of this ticket is to add this filtering to the database query itself so that cafes are only returned if the current time is after the opening time and before the closing time (see assumptions and considerations below for adjustments to this).

IMPORTANT NOTE: The filtering described should be performed IN THE DATABASE QUERY ITSELF and not by filtering the results that are returned. This is a complex ticket with many different aspects. Feel free to pair and ask for help where needed. This will break current API tests. This is expected and adjustments will need to be made. It is not your responsibility to do so but do let the group know.

Assumptions:

Opening times in the cafe model and database: The openingHours property in the cafeSchema is a placeholder and may be adjusted to suit what makes best sense to anyone taking this ticket. It is currently an array of objects. One for each day but adjust as needed. Once a format has been decided on, or provisionally if you prefer, seed data must be made to suit this format. See the seed-data directory for current seeds. This can then be used to seed the database (see README.md). Currently, no databases contain data with opening times.

Process: It makes sense to work out the openingTimes data structure first and then create seed data and seed the database before working on the query but you may also choose to work on the query to inform the data structure. Just be aware that no testing can really be performed until there is data in the database to test against. It is very much up to you.

Acceptance criteria: