How to structure booking app for scheduled tasks? - ruby-on-rails

I want to build a whitelabel booking app for offline services that are organized the team members schedule.
A good example would be a hair salon: There are several team members working for several hours daily and customers can book various services that take different amounts of time to complete. The customers should see which timeslots would still be available to book their services so that the schedules of the team members get filled up automatically.
My questions is: How should I model this in the database? I know this problem has been solved a million times but I could not find any information on a pattern for this.
My Suggestion:
A table that holds all the available timeslots in 10min pieces of all the team members for the next 4 weeks
A cron writes the newly available hours (in 4 weeks) into the table every week
As the customers book services of the lengths of 30min, 60min etc. 3 or 6 of these 10min timeslots are assigned to the order
I hope this makes sense. I would very thankful for hints to any patterns for scheduling apps of critique on my suggestion :)

Related

Youtube Data API reduced to Zero Queries per day (Audit / Form)

i have a project on Google Cloud Platform, using the Youtube Data V3 API. Everything was going well, earlier this month after receiving several emails alerting that I had to do an Audit, the queries for the day stopped completely. they were completely zeroed.
I followed the link to perform the Audit, and i successfully completed all the changes that were told to me in my application, strictly following the regulations. The audit went well. No further changes were required from me.
But the issue is that the queries per day remain at zero. I can't edit. It occurred to me that maybe using the Google Cloud Trial there could be some change. Negative. I'm still unable to increase the limits, not even using the balance they give you as a gift.
The project used approximately a margin of about 25,000 to 300,000 queries / day. I have requested 500.000 queries / day filling in the quota expansion form to have a little more margin.
Meanwhile the project has been stopped for almost a month. If anyone knows something or how I should proceed about it,
Thank you very much.
Have a nice day,

Does Ejabberd/XMPP have a Limit on Auto-Join MUC?

I am currently in the process of developing an application that essentially offers multiple conferences/rooms to each user at once.
In other words, an individual user can be in as many rooms as they would like at any one time...
However, whilst this currently works for 10/11 (it varies) rooms, as soon as the user attempts to join more rooms, it fails.
Originally I thought this was as a result of the front-end iOS, but having now tested 10+ rooms with InstantBird (MacOS XMPP Client), I can confirm that the issue seems to be at the ejabberd end...
Thus far, I have been unable to extract any sort of error message returned. I have checked the logs and everything seems fine (I may be missing something as I am not really sure what to look for).
I have a couple of ideas as to what it might be but I don't really know where to start:
Does Ejabberd limit the number of rooms a user can join at any one time?
Does Ejabberd have a timeout that may be exceeded when trying to join multiple rooms (this would explain why it varies between 10 and 12 rooms max)?
Your answer is here:
https://docs.ejabberd.im/admin/guide/configuration/#modmuc
There is a config property
max_user_conferences
and as documentation tells us:
This option defines the maximum number of rooms that any given user can join. The default value is 10. This option is used to prevent possible abuses. Note that this is a soft limit: some users can sometimes join more conferences in cluster configurations.

Medium scale repeated tasks in Rails

I'm building a web app that tracks stats for a game. The API for that game (Steam Web API) only allows me to retrieve data from the most recently played match.
When a user requests their stats to be tracked, I need make a call to the Steam Web API every 10 minutes or so to check if they have played another match, then store it in the database if they have. The problem is, I check every 10 minutes for every user...
Is there a way to schedule this efficiently so that the server doesn't get overloaded? This application could potentially server 10,000+ users.
Please feel free to correct anything in this question if I got something obviously wrong.
There are many gems for recurring events in ruby, like:
ice cube
recurrence
However, if you are going to have lots of users, and you are worried about server load, I would suggest not using your rails app to do this.
Instead, build another service which doesn't run on your rails app to update your database with statistics.
Having an independent service like this decoupled from your main app allows you to easily put it on another server, and/or have it scale independently from your webapp.

Ruby on Rails Job Scheduling Options

I'm going to try again after my hiccup last night. The following is what I'm trying to find a solution to: After conditions in my controller are met, I need to run a job five minutes later. This is for a lottery website for a mmo. After a ticket is sold, based on specific conditions(player amount met, amount of lottery item met), players have five minutes to buy a tickets. After five minutes, I need to pick random unique ticket numbers and award winners tokens. Right now I run this manually. I'm looking for a solution that I can schedule in my controller to run five minutes later.
I have tried delayed_job which I cannot get to work locally on a mac. Ruby on Rails Delayed Job Local Wont Run I have tried iron.io paid solution with no luck.
Please offer suggestions with possible tutorials.
Thanks.
Sidekiq is great and you should try it first.
https://github.com/mperham/sidekiq
Mike Perham, the lead author, is a terrific programmer and he writes about comparisons among Sidekiq, Resque, Delayed Job.
Worth reading his blog post about it here:
http://www.mikeperham.com/2011/05/04/background-processing-vs-message-queueing/

Implementing an Online Waiting Room

My organization is building a new version of our ticketing site and is looking for the best way to build an online waiting room when the number of users in our purchase path exceeds a certain limit. The best version of this queue would let new users in after existing users have either completed their purchase or have exceeded a timeout limit after entering the path.
I'm trying to get an idea of how this has been implemented by other organizations. Has anyone out there done something similar or have any experience with this? We have some ideas, but I'd like to get a sense of what solutions have been tried and what problems those solutions have run up against.
Just to be complete, this site is being built in Ruby on Rails, though I'd love to hear about how people have solved this regardless of platform.
Edit: To clarify: The need for the queue is not primarily to reduce load, but to limit the speed at which the web is purchasing tickets relative to people buying in other ways, like over the phone.
Before I outline one method for this, I want to point out that what you want to do doesn't make a lot of sense. Services on the web aren't like a physical store, where I can walk up and see that it's crowded and decide to stay or not. Queueing people on your site strikes me as shifting the blame from you (unable or unwilling to adequately provision resources) to me (punishing me for trying to use your site).
If you're selling something like show tickets, where quantity is limited and each item is tied to a seat, I think it's better to reserve items and time out those reservations if they aren't paid for in a timely manner. Ticketmaster does this, and I think it's a much better solution than blocking people at the door.
If you still want to go down this path, then I'd design the system like this:
As customers come to your site, record their arrival time. As they interact with the site, record a "last seen" time. "Last seen" will be used to determine activeness. You'll need a background job running very frequently to expire sessions quickly.
Once your limit is hit, you have an ordered queue of people who are blocked. As customers complete their transaction or time out, you'll mark the next person in the queue for entry into the purchase path.
For queued users, their browsers will make a request on a regular basis, checking to see if you've let them in yet. If yes, they proceed to the purchase path. If no, they continue to wait.
The purchase path needs a mechanism to check if someone is trying to circumvent your waiting area, and sends them back.
You might find the Online queuing for ticketing guide helpful. Check their repository at GitHub.
They've integration with Ruby On Rails, PHP, .NET, iOS, Android and similar platforms.
Queue-it enables you to gain control of website overload during extreme traffic peaks by offloading end users into an online queue.
When a peak traffic event occurs on a website, the online queue system sends users to the virtual waiting room environment where the users wait and are redirected back to the website at a rate it can handle.

Resources