eisbuk / EisBuk

Manage bookings for ice skating lessons
GNU Affero General Public License v3.0
0 stars 1 forks source link

Improve `queryAuthStatus` firestore customer query #933

Closed silviot closed 7 months ago

silviot commented 7 months ago

Currently queryAuthStatus (a function that is called by every client on every page load, and that blocks usage until it returns) reads in all customers and loops through them to find matches for phone/email.

It could instead use two indices and two where queries.

I believe the indices are automatically created by firebase already.

There were two small fixes still to do in #932 that makes sense to do in this context.

It also makes sense to fix this sentry entry in this context. The gist of it is that the line

        const { email, phone_number: phone } = auth!.token!;

in auth.ts causes an error if the function is called by an unauthenticated user. I was testing the function with curl, so it's very much possible a similar thing never happens using the app. Still, it makes sense to not throw an exception in that case.