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:
Our current model assumes that each cafe has a single opening and closing time each day. We may need to adjust this later but logic should follow that assumption.
The best match cafe may opening soon, so it makes sense to accept cafes that will open in, e.g. 15 minutes time. Create a variable for this period so it can easily be adjusted.
A cafe that is about to close if not helpful. The query should filter out any cafe that will close in the next, e.g. 20 minutes. Again, create a variable for this for easy adjustment.
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:
[ ] The cafe model is amended as required for the finalised openingHours data structure.
[ ] Existing seed data is updated with opening hours (this does not need to be accurate data with the actual times, just workable).
[ ] The test database is seeded with the updated seed data.
[ ] The filtering of cafes by opening times is performed in the query rather than returned data.
[ ] Cafes are returned when they also match location and facility criteria (this is already in place but should be confirmed and still working).
[ ] Cafes may be returned if they open within 15 minutes.
[ ] cafes may NOT be returned if they close within 20 minutes.
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: