New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get availability for a bookable #22
Comments
The availability of a bookable is calculated at runtime, given an hash of options. This hash of options must provide all the condition requested by a booking instance, included the time (or interval) at which you want to book the resource (if :time_type != :none). As you can see in the source code, there are complex calculations to understand if the bookable is really available, and it's not possible to have a list of availabilities without making those calculations for each possible time. I imagine a feasible similar feature. It would be a function "bookable.get_availabilities(from: start_time, to: end_time)" that iterates over the slots of the schedule, but limiting the calculation between the given interval. PRs or suggestions are appreciated |
@Chosko I'm interested in this as well and can help. Would it depend on the schedule you assign to the bookable? For example, if a bookable is available daily for a day at a time, could you loop through the bookings, create an array of the days the bookable is booked, and subtract it from an array that reflects the days of the month. Obviously a simple use case, but maybe it can be applied to some more complicated ones - with the idea being to limit the infinite number of slots such that one can define how far in advance you want to print out the available ones. |
I'm interested in a solution and am also available to help. I also need the algorithm to be efficient, because I'm planning on having 15 min schedule intervals per Bookable. So worst case, that is 96 intervals per day multiplied by 8 = 768, where N is equal to 8. I'm not sure how schedule is serialized as :text, but maybe there needs to be a separate DB construct to model availability more efficiently? |
I know that this is an old issue, but ...has anyone been able to implement this ? My dumb implementation is not working correctly:)
|
Hi,
I was wondering if there is a way I can get the available times for a specific bookable.
My bookable at the moment is created like this:
So ideally I would like to display a list of "available times" which can be reserved, based on current availability. I don't want to show a full list of the slots mentioned in the snippet above, rather only the available ones.
I would imagine doing
session.availability
(which doesn't exist) and getting back a list.Any advice on how I can achieve this?
The text was updated successfully, but these errors were encountered: