Skip to content

Conversation

@KesterJJ
Copy link
Contributor

The conditions were previously mutually exclusive with a negative time_before value, so the email would never send. We need to allow for negative values so the email can send X minutes after the meeting time but before the booking is released.

…before value

The conditions were previously mutually exclusive with a negative time_before value, so the email would never send. We need to allow for negative values so the email can send X minutes after the meeting time but before the booking is released.
@KesterJJ KesterJJ requested review from chillfox and w-le October 16, 2025 10:27
@w-le
Copy link
Contributor

w-le commented Oct 21, 2025

hey @chillfox can we get your review as you're the main author of this driver?

@KesterJJ
Copy link
Contributor Author

When the time_before is set to a negative value, the conditions for sending the email skip the exact moment at which the email would be sent. By changing the sign to <=, that moment is included and the email should send.
e.g. with -5 set as the time_before:

1st condition:
booking.booking_start - now < -5 * 60

booking.booking_start - now < -300

2nd condition:
now - booking.booking_start > 300

Both conditions need to be true for the email to send. But at the moment of 300 seconds past the booking time, both conditions are not true. This is exactly when the email would send so it is not triggered.

Copy link
Contributor

@chillfox chillfox left a comment

Choose a reason for hiding this comment

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

mostly looks good.
Just remove the end, run crystal tool format drivers/place/auto_release.cr to ensure consistent formatting. Make sure it compiles crystal build drivers/place/auto_release.cr and run the specs in the test harness to see if any needs to be changed with the change in logic.

(booking.booking_start - Time.utc.to_unix <= @auto_release.time_before(booking.booking_type) * 60) &&
(Time.utc.to_unix - booking.booking_start <= @auto_release.time_after(booking.booking_type) * 60)
logger.debug { "sending release email to #{booking.user_email} for booking #{booking.id} as it is within the time_before window" }
end
Copy link
Contributor

Choose a reason for hiding this comment

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

This end should not be there.

@w-le w-le changed the title fix(place/auto_release): fix logic so email sends with negative time_… [PROJ-1523] fix(place/auto_release): fix logic so email sends with negative time_… Oct 22, 2025
@w-le
Copy link
Contributor

w-le commented Oct 22, 2025

perfect advice, thanks @chillfox !

fyi @KesterJJ the crystal tool format advice applies to all driver changes btw (not just this one), and likewise with ensuring the driver compiles, which you can also do by using the driver test harness (as I mentioned).

@KesterJJ
Copy link
Contributor Author

OK, @chillfox I have removed the "end" and added a couple of test results to the spec file that it was expecting to see. It now passes the test harness. Please verify and merge if those changes are ok.

Copy link
Contributor

@chillfox chillfox left a comment

Choose a reason for hiding this comment

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

LGTM

Please run crystal tool format in the future, as it makes the diffs much easier to read for review.

@chillfox chillfox merged commit cb163b4 into master Oct 23, 2025
2 of 5 checks passed
@KesterJJ KesterJJ deleted the fix(place/auto_release)-fix-logic-so-email-sends-with-negative-time_before-value branch October 23, 2025 09:31
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.

4 participants