-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
chore: Create BookingCreatedService
CAL-[5026]
#18516
base: main
Are you sure you want to change the base?
Conversation
referencesToCreate = createManager.referencesToCreate; | ||
videoCallUrl = evt.videoCallData && evt.videoCallData.url ? evt.videoCallData.url : null; | ||
if (!isDryRun) { | ||
await BookingListener.create({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BookingListener.create() reads weird. If it’s a listener, why is it creating anything?
Seems like we need to switch to the pub/sub naming convention.
BookingPublisher/BookingSubscriber
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or BookingService
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the confusion. .create()
refers to when a booking is created. I'm hoping to add BookingListener.reschedule()
, BookingListener.cancel()
.
I was debating on BookingListener.bookingCreated()
, would that be clearer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. It's the fact that it's called BookingListener
. Typically classes with name Listener
don't have functions like .create()
or .reschedule()
. They are typically just .listen()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you plan to add those functions, BookingService
operating as an application service makes a lot more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, in many big systems like ours with complex code, a service per operation is sometimes preferred. e.g. BookingCreationService
, BookingRescheduleService
, etc.
results = createManager.results; | ||
referencesToCreate = createManager.referencesToCreate; | ||
videoCallUrl = evt.videoCallData && evt.videoCallData.url ? evt.videoCallData.url : null; | ||
if (!isDryRun) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A benefit is we don't have to wrap (!isDryRun)
around multiple functions.
); | ||
} | ||
} | ||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the post booking actions are taken we can return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note some post booking functions we need to keep in handleNewBooking
as they're being used for rescheduled bookings, payments, and setting up bookings that require confirmation.
}; | ||
|
||
loggerWithEventDetails.error( | ||
`EventManager.create failure in some of the integrations ${organizerUser.username}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the following removed code can be moved to the BookingListener
@@ -1832,67 +1710,8 @@ async function handler( | |||
|
|||
loggerWithEventDetails.debug(`Booking ${organizerUser.username} completed`); | |||
|
|||
// We are here so, booking doesn't require payment and booking is also created in DB already, through createBooking call | |||
if (isConfirmedByDefault) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These calls are moved to the booking listener
noEmail?: NoEmail; | ||
reqAppsStatus?: ReqAppsStatus; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These properties only exist in handleNewBooking
although we'll need to access these in the tasker.
return calculateAggregatedAppsStatus(reqAppsStatus, resultStatus); | ||
} | ||
|
||
return resultStatus; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In updateBookingWithStatus
the resultStatus
is returned
@@ -108,6 +110,13 @@ const handleSeats = async (newSeatedBookingObject: NewSeatedBookingObject) => { | |||
...reqBodyMetadata, | |||
}; | |||
try { | |||
const workflows = await getAllWorkflowsFromEventType( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved getAllWorkflowsFromEventType
from being called in handleNewBooking
to either being called in handleSeats
or BookingListener.create()
referencesToCreate = createManager.referencesToCreate; | ||
videoCallUrl = evt.videoCallData && evt.videoCallData.url ? evt.videoCallData.url : null; | ||
if (!isDryRun) { | ||
await BookingListener.create({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the confusion. .create()
refers to when a booking is created. I'm hoping to add BookingListener.reschedule()
, BookingListener.cancel()
.
I was debating on BookingListener.bookingCreated()
, would that be clearer?
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
BookingListener
and .create
methodBookingCreatedService
BookingCreatedService
BookingCreatedService
CAL-[5026]
What does this PR do?
Aims to abstract post booking created code from
handleNewBooking
into a new classBookingListener
This PR starts with creating a
.create()
method on theBookingListener
The follow post booking actions are added to the method
Fixes #XXXX (GitHub issue number)
Fixes CAL-XXXX (Linear issue number - should be visible at the bottom of the GitHub issue description)
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?