0

I have to build an app that manages orders between customers who submit the orders and riders who deliver them. Riders work in shifts, so when a customer submits an order, only the riders that are active in that particular shift should recieve a notification.

I chose Firebase as backend for my app, so I'd use cloud firestore, cloud functions, auth and FCM.

My question is: how should I organize my data to achieve what I've mentioned before?

I've already made some options:

  1. I have a collections for shifts, where all riders active in that shift are recorded. When an order is submitted, then i query all the riders active in that shift (queried by time) and then send a notification to each one.
  2. I have a message topic where active riders are subscribed, and then i post the notification there.

Option #1 seems too cumbersome for me. There are a lot of queries to do. Option #2 doesn't need a query at all, but how should i handle riders subscriptions to it (to be more precise, how can active riders in that shift subscribe to the topic) ?

8
  • I guess the app is not backed by a proprietary backend. Right? The interaction is app <-> Firebase. Do you track raiders' state? I mean, when they are active and available to pick the next job (delivery)? Commented May 27, 2019 at 10:49
  • Yes, you hit the point. I only interact with firebase. And yes, when a rider picks a job cannot pick another one until he completes the delivery. Commented May 27, 2019 at 11:30
  • Are these shifts always the same? I mean could you create topics per shift? Commented May 27, 2019 at 12:32
  • Well, for each day shift are quite the same. For instance, a day could be split in 4-hours shifts. The problem is that my sakeholders want to be able to customize shifts. In particular, they want that every week, riders have to pre-subscribe to the shifts of the next week, so that they know who is warking in each shift a week before. I don't know if I was clear. Commented May 27, 2019 at 12:47
  • This pre-subscription happens at the end of the current shift? Anytime between the current date and the starting date of the next shift? Commented May 27, 2019 at 13:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.