trisignia
trisignia

Reputation: 1183

Queue management & predictions with Ruby on Rails

I'm building a restaurant-management app with Rails, and I'm a little stuck when it comes to predicting when tables might open up for guests on a waitlist.

A typical example: if we make it easy and assume there are 10 one-person tables in the restaurant, and that they're all occupied right now, and there are 10 individual diners on the waitlist, how long will the eleventh person have to wait for his table if we can assume each diner will stay for 30 minutes?

I'm not looking for actual code for this sort of problem,* but I'd appreciate advice about things to look at/consider.

Is this some sort of FIFO queue? Should I be looking at set theory? Network theory? Are there any stdlibs that are helpful in building out a system like this?

Thanks in advance for your help!

*but if there's relevant code out there, I'd of course be happy to see it!

Upvotes: 1

Views: 409

Answers (1)

megas
megas

Reputation: 21791

You could create Table model. This model has a flag(boolean) - occupied and free. Every time when a customer occupied and released the table a system should change this flag accordingly. This functionality will automatically change updated_at time in database. So in case the table is occupied then the release time will be updated_at + 30 minutes. Next you can ask all tables to calculate the nearest time of releasing the table.

Upvotes: 1

Related Questions