update concurrentCapacity
This commit is contained in:
@@ -388,6 +388,7 @@ export class BookingsService {
|
||||
|
||||
const windows = await this.loadAvailabilityWindows(businessId);
|
||||
const busy = await this.loadBusyIntervals(businessId, dateYmd);
|
||||
const concurrentCapacity = await this.getConcurrentCapacity(businessId);
|
||||
|
||||
const slots = generateAvailableSlotStarts({
|
||||
dateYmd,
|
||||
@@ -396,11 +397,21 @@ export class BookingsService {
|
||||
slotStepMinutes: 15,
|
||||
windows,
|
||||
busy,
|
||||
concurrentCapacity,
|
||||
});
|
||||
|
||||
return { date: dateYmd, slots, totalDurationMinutes };
|
||||
}
|
||||
|
||||
private async getConcurrentCapacity(businessId: string): Promise<number> {
|
||||
const business = await this.businessRepo.findOne({
|
||||
where: { id: businessId },
|
||||
select: ['id', 'concurrentCapacity'],
|
||||
});
|
||||
const value = business?.concurrentCapacity ?? 1;
|
||||
return Math.max(1, value);
|
||||
}
|
||||
|
||||
private async loadAvailabilityWindows(
|
||||
businessId: string,
|
||||
): Promise<AvailabilityWindow[]> {
|
||||
@@ -647,6 +658,7 @@ export class BookingsService {
|
||||
);
|
||||
}
|
||||
|
||||
const concurrentCapacity = await this.getConcurrentCapacity(businessId);
|
||||
const slots = generateAvailableSlotStarts({
|
||||
dateYmd,
|
||||
durationMinutes,
|
||||
@@ -657,6 +669,7 @@ export class BookingsService {
|
||||
excludeBookingId,
|
||||
excludeBookingGroupId,
|
||||
}),
|
||||
concurrentCapacity,
|
||||
});
|
||||
|
||||
const scheduledMs = scheduledAt.getTime();
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import {
|
||||
IsBoolean,
|
||||
IsInt,
|
||||
IsLatitude,
|
||||
IsLongitude,
|
||||
IsOptional,
|
||||
IsString,
|
||||
IsUUID,
|
||||
Matches,
|
||||
Max,
|
||||
MaxLength,
|
||||
Min,
|
||||
} from 'class-validator';
|
||||
|
||||
export class UpdateBusinessDto {
|
||||
@@ -76,4 +79,16 @@ export class UpdateBusinessDto {
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
serviceClassesEnabled?: boolean;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
example: 1,
|
||||
description: 'How many customers can be served at the same time',
|
||||
minimum: 1,
|
||||
maximum: 20,
|
||||
})
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(20)
|
||||
concurrentCapacity?: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user