apc-mhs / mustang-mug

The website, backend, and dashboard for the Mustang Mug Cafe
https://mug.apc-mhs.com
1 stars 0 forks source link

Optimize current purchase window updating #208

Open AndrewLester opened 3 years ago

AndrewLester commented 3 years ago

Currently updateCurrentPurchaseWindow fetches all purchase windows in order to loop through them and check which one is the current window. It does this through a call to getDocuments with the collection name 'purchase_windows'.

This call could be replaced by a call to getDocumentsWhere with a condition to only find purchase windows that have the same dayOfWeek as the current day. Specify this condition in the function's queryOnQueryable parameter. Something like:

(queryable) => queryable.where('dayOfWeek', '==', new Date().getDay());