unc-csxl / csxl.unc.edu

CS Experience Labs' web application.
https://csxl.unc.edu
MIT License
9 stars 7 forks source link

[Hi-Pri!] Room Reservation not showing as Reserved #383

Closed KrisJordan closed 4 months ago

KrisJordan commented 4 months ago

Step to reproduce:

  1. Create a reservation for tomorrow
  2. Go to create another reservation
  3. The blue boxes for Your Reservations are not showing

Two reservations I created showing in backend:

Screenshot 2024-03-31 at 11 36 31 PM

Also showing in my coworking home:

Screenshot 2024-03-31 at 11 36 56 PM

Not showing in the new reservation screen:

Screenshot 2024-03-31 at 11 37 13 PM
yuvrajjain2003 commented 4 months ago

Huh. Interesting. I'll take a look right away!

KrisJordan commented 4 months ago

I'll add you as admin on XL site so you can see the XL Ambassadors view there, as well

KrisJordan commented 4 months ago

I can reproduce in dev, as well, on main branch

yuvrajjain2003 commented 4 months ago

Yeah! I'm not sure how that slipped by. I'm working on this right now. I think I may have an idea as to why this might be happening

KrisJordan commented 4 months ago

I'm probably about to call it a night in the next 15, but I will be up pretty early and can merge/deploy then. If you can't find it quick, just pick it back up tomorrow don't lose sleep over it.

We are successfully blocking reservations that overlap, so no real danger just potentially annoyance in the short term if someone tries to reserve something that's already been reserved.

Thanks for jumping on this!

yuvrajjain2003 commented 4 months ago

Huh. This is really weird. I opened this up on local host and sure enough encounter the same problem. However, I changed the time back to around 11 am just to check whether this was something to do with operating hours spanning between two days since it's almost midnight.

Turns out that if I set my local date & time on my device to 11 am or any time within the 10 am to 6 pm duration, everything seems to work fine. However there is something strange happening after hours... really weird

KrisJordan commented 4 months ago

It has to be in one of the couple of relevant method lines modified here, right: https://github.com/unc-csxl/csxl.unc.edu/commit/b29e7f68b1f6575fd623d709d5d19a7d7f9ddedc

Without my loading up the full logic, I wonder if your described symptoms map to these logical changes in an interesting way. Given some logic seems relative to "current time" it feels likely to be here.

KrisJordan commented 4 months ago

After midnight, it's now working in prod for today and tomorrow. This is a fun bug :) It seems perhaps related to following the close of operating hours on a given day?

KrisJordan commented 4 months ago

Since it's plausibly working until 7pm tomorrow/today now, we can pick back up tomorrow! Thanks again for moving quickly.

(realizing my operating hours theory likely isn't it because after reset demo we should be open, maybe it's the 23rd hour of the day...)

aarjavjain2002 commented 4 months ago

It appears to be working fine now that it is 12AM so it does seem to only be present between the end of operating hours and midnight.

yuvrajjain2003 commented 4 months ago

Welp. I figured out the issue. This was the saddest bug ever.

                if date.date() == current_time.date():
                    if end_idx < current_time_idx:
                        continue
                    start_idx = max(current_time_idx, start_idx)

Just had to add in the condition for date.date() == current_time.date() to make sure I was not skipping over reservations when end_idx < current_time_idx for reservations in the future :/