Skip to content
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

Fix limited booking options bug #227

Merged
merged 3 commits into from
Jan 15, 2024
Merged

Conversation

MelissaAutumn
Copy link
Member

Fixes #213

We were converting the start and end time to utc, which caused us North Americans to have a 9-5 translate to something like 17 - 1 after utc conversion.

I ended up re-writing the function (sorry 😄).

Basically we loop between the earliest_booking and the end time (either schedule_end or farthest_booking), check if it's a valid day within the schedule's weekday selection, and finally build that days slots between the start_time and end_time (accounting for the timezone conversion issue.)

There's a few problems with this (and I believe also the previous code but correct me if I'm wrong!) where the earliest_booking time doesn't account for bookable days, just any day that comes up. So if I only allow people to book me on weekdays, and I have my earliest booking set to 24 hours, then people can still book me on Monday.

That ux is kind of weird too, I'm not sure if I fully remember how that should work. Maybe a thing to discuss at the next meeting 😄

@MelissaAutumn MelissaAutumn self-assigned this Jan 12, 2024
@MelissaAutumn
Copy link
Member Author

Another fix to this issue would be not converting the start_time and end_time to utc on the frontend, however also gets tricky because every other date is utc. Just wanted to mention it was something I thought about 😄

@devmount
Copy link
Collaborator

I will test this thoroughly on Monday and report back. And no reason to say sorry for replacing my ugly function with something way more elegant 👍🏻

Yes we could send dates with tz information to the backend, but I decided to base everything on UTC for keeping things simple and no headaches while thinking about where to use UTC and where TZ dates...

Copy link
Collaborator

@devmount devmount left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some testing with differen timezones and looks like schedule slots are correctly genereated. Good job!

backend/src/appointment/controller/calendar.py Outdated Show resolved Hide resolved
@MelissaAutumn
Copy link
Member Author

Thanks!

@MelissaAutumn MelissaAutumn merged commit 7013248 into main Jan 15, 2024
1 check passed
@MelissaAutumn MelissaAutumn deleted the bugs/213-limited-booking-options branch January 15, 2024 16:05
devmount added a commit that referenced this pull request Jan 15, 2024
* Fix available_slots_from_schedule to account for end_time being in the next day.

* Add tzinfo as a dependency for ZoneInfo

* 📜 update comments

---------

Co-authored-by: Andreas Müller <[email protected]>
@MelissaAutumn MelissaAutumn restored the bugs/213-limited-booking-options branch January 15, 2024 17:03
@devmount devmount deleted the bugs/213-limited-booking-options branch March 26, 2024 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Limited Booking Options
2 participants