This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type EventType = string; | |
export interface Event { | |
type: EventType; | |
} | |
export interface EventPublisher { | |
publish<T extends Event>(event: Event): Promise<void> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class RatingAppointmentListener { | |
constructor(@Inject(EVENT_SUBSCRIBE_SERVICE_TOKEN) eventSubscribeService: EventSubscribeService, | |
@Inject(RatingGateway) private readonly ratingGateway: RatingGateway) { | |
this.onAppointmentCreated = this.onAppointmentCreated.bind(this) | |
eventSubscribeService.subscribe(APPOINTMENT_CREATED_EVENT_TYPE, this.onAppointmentCreated) | |
} | |
async onAppointmentCreated(event: AppointmentCreatedEvent) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class AppointmentService { | |
constructor(@InjectRepository(Appointment) private readonly repository: Repository<Appointment>, | |
@Inject(AppointmentPermissionService) private readonly appointmentPermissionService: AppointmentPermissionService, | |
@Inject(EVENT_PUBLISHER_TOKEN) private readonly eventPublisher: EventPublisher) {} | |
async create(values: DeepPartial<Appointment>, currentUser: User) { | |
await this.appointmentPermissionService.verifyCanCreate(currentUser, values) | |
const appointment = await this.repository.save(values) | |
await this.eventPublisher.publish(makeAppointmentCreatedEvent(appointment.id)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const APPOINTMENT_CREATED_TYPE = 'event/appointment/created' | |
export interface AppointmentCreatedEvent extends Event { | |
type: typeof APPOINTMENT_CREATED_TYPE | |
appointmentId: string | |
} | |
export function makeAppointmentCreatedEvent(appointmentId: string) { | |
return { | |
type: APPOINTMENT_CREATED_TYPE, | |
appointmentId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type EventType = string; | |
export interface Event { | |
type: EventType; | |
} | |
export interface EventPublisher { | |
publish<T extends Event>(event: Event): Promise<void> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class AppointmentService { | |
constructor(@InjectRepository(Appointment) private readonly repository: Repository<Appointment>, | |
@Inject(QuotationService) private readonly quotationService: QuotationService, | |
@Inject(WorkOrderService) private readonly workOrderService: WorkOrderService, | |
@Inject(NotificationService) private readonly notificationService: NotificationService, | |
@Inject(StatusChangeHistoryService) private readonly statusChangeHistoryService: StatusChangeHistoryService, | |
@Inject(AppointmentPermissionService) private readonly appointmentPermissionService: AppointmentPermissionService, | |
@Inject(RatingServiceGateway) private readonly ratingServiceGateway: RatingServiceGateway) {} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class AppointmentService { | |
constructor(@InjectRepository(Appointment) private readonly repository: Repository<Appointment>, | |
@Inject(QuotationService) private readonly quotationService: QuotationService, | |
@Inject(WorkOrderService) private readonly workOrderService: WorkOrderService, | |
@Inject(NotificationService) private readonly notificationService: NotificationService, | |
@Inject(StatusChangeHistoryService) private readonly statusChangeHistoryService: StatusChangeHistoryService, | |
@Inject(AppointmentPermissionService) private readonly appointmentPermissionService: AppointmentPermissionService) {} | |
async create(values: DeepPartial<Appointment>, currentUser: User) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class AppointmentService { | |
constructor(@InjectRepository(Appointment) private readonly repository: Repository<Appointment>, | |
@Inject(QuotationService) private readonly quotationService: QuotationService, | |
@Inject(WorkOrderService) private readonly workOrderService: WorkOrderService, | |
@Inject(EmailService) private readonly emailService: EmailService, | |
@Inject(StatusChangeHistoryService) private readonly statusChangeHistoryService: StatusChangeHistoryService, | |
@Inject(AppointmentPermissionService) private readonly appointmentPermissionService: AppointmentPermissionService) {} | |
async create(values: DeepPartial<Appointment>, currentUser: User) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def histogram_match(reference, input): | |
reference_histogram = defaultdict(int) | |
input_histogram = defaultdict(int) | |
for letter in reference.lower(): | |
reference_histogram[letter] += 1 | |
for letter in input.lower(): | |
input_histogram[letter] += 1 |