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());
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 togetDocuments
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 samedayOfWeek
as the current day. Specify this condition in the function'squeryOnQueryable
parameter. Something like: