perf: 优化空场监控
This commit is contained in:
@@ -76,8 +76,11 @@ export interface UpdateCourtSettingsInput {
|
||||
export interface CreateBookingInput {
|
||||
courtId: string
|
||||
date: string
|
||||
slotId: string
|
||||
slotId?: string
|
||||
slotIds?: string[]
|
||||
expectedPriceCents: number
|
||||
expectedStartTime?: string
|
||||
expectedEndTime?: string
|
||||
}
|
||||
|
||||
export interface CancelBookingInput {
|
||||
@@ -112,6 +115,64 @@ export interface MonitorTask {
|
||||
lastCheckedAt?: string
|
||||
lastError?: string
|
||||
availableCount: number
|
||||
stats: MonitorTaskStats
|
||||
autoBooking: MonitorAutoBookingState
|
||||
}
|
||||
|
||||
export type MonitorAutoBookingStatus =
|
||||
| 'disabled'
|
||||
| 'armed'
|
||||
| 'attempting'
|
||||
| 'pending-payment'
|
||||
| 'blocked'
|
||||
| 'stopped'
|
||||
|
||||
export interface MonitorAutoBookingState {
|
||||
enabled: boolean
|
||||
status: MonitorAutoBookingStatus
|
||||
attemptCount: number
|
||||
lastAttemptAt?: string
|
||||
lastError?: string
|
||||
orderId?: string
|
||||
bookedAt?: string
|
||||
bookedDate?: string
|
||||
bookedSlotLabel?: string
|
||||
}
|
||||
|
||||
export interface MonitorTaskStats {
|
||||
totalChecks: number
|
||||
successfulChecks: number
|
||||
partialFailureChecks: number
|
||||
failedChecks: number
|
||||
alertsSent: number
|
||||
availableObservations: number
|
||||
lastAlertAt?: string
|
||||
}
|
||||
|
||||
export interface MonitorDailyStats {
|
||||
date: string
|
||||
checks: number
|
||||
failedChecks: number
|
||||
alerts: number
|
||||
availableObservations: number
|
||||
maxAvailable: number
|
||||
}
|
||||
|
||||
export interface MonitorTaskLog {
|
||||
id: string
|
||||
occurredAt: string
|
||||
type: 'check' | 'alert' | 'error' | 'lifecycle' | 'booking'
|
||||
level: 'info' | 'warning' | 'success'
|
||||
message: string
|
||||
availableCount?: number
|
||||
checkedDateCount?: number
|
||||
failedDates?: string[]
|
||||
}
|
||||
|
||||
export interface MonitorTaskDetail {
|
||||
task: MonitorTask
|
||||
dailyStats: MonitorDailyStats[]
|
||||
logs: MonitorTaskLog[]
|
||||
}
|
||||
|
||||
export interface CreateMonitorTaskInput {
|
||||
@@ -119,6 +180,7 @@ export interface CreateMonitorTaskInput {
|
||||
targetDate?: string
|
||||
startTime: string
|
||||
endTime: string
|
||||
autoBookingEnabled?: boolean
|
||||
}
|
||||
|
||||
export interface MonitorAlert {
|
||||
@@ -140,8 +202,10 @@ export interface TennisBookApi {
|
||||
cancelBooking(input: CancelBookingInput): Promise<void>
|
||||
getPendingBooking(courtId: string): Promise<PendingBooking | null>
|
||||
listMonitorTasks(): Promise<MonitorTask[]>
|
||||
getMonitorTaskDetail(taskId: string): Promise<MonitorTaskDetail>
|
||||
createMonitorTask(input: CreateMonitorTaskInput): Promise<MonitorTask>
|
||||
setMonitorTaskEnabled(taskId: string, enabled: boolean): Promise<MonitorTask>
|
||||
setMonitorTaskAutoBooking(taskId: string, enabled: boolean): Promise<MonitorTask>
|
||||
deleteMonitorTask(taskId: string): Promise<void>
|
||||
takeMonitorAlerts(): Promise<MonitorAlert[]>
|
||||
onMonitorAlert(listener: () => void): () => void
|
||||
@@ -156,8 +220,10 @@ export const IPC_CHANNELS = {
|
||||
cancelBooking: 'bookings:cancel',
|
||||
getPendingBooking: 'bookings:pending',
|
||||
listMonitorTasks: 'monitors:list',
|
||||
getMonitorTaskDetail: 'monitors:detail',
|
||||
createMonitorTask: 'monitors:create',
|
||||
setMonitorTaskEnabled: 'monitors:set-enabled',
|
||||
setMonitorTaskAutoBooking: 'monitors:set-auto-booking',
|
||||
deleteMonitorTask: 'monitors:delete',
|
||||
takeMonitorAlerts: 'monitors:take-alerts',
|
||||
monitorAlert: 'monitors:alert'
|
||||
|
||||
Reference in New Issue
Block a user