@@ -39,11 +39,9 @@ export const createAlerts = async (): Promise<void> => {
3939 }
4040
4141 const date = momentTimezone . tz ( 'America/Sao_Paulo' ) ;
42- const startDate = date . hours ( ) < 12 ? date . clone ( ) . hours ( 0 ) . minutes ( 0 ) . seconds ( 0 ) : date . clone ( ) . hours ( 12 ) . minutes ( 0 ) . seconds ( 0 ) ;
43- const endDate = date . hours ( ) < 12 ? date . clone ( ) . hours ( 11 ) . minutes ( 59 ) . seconds ( 59 ) : date . clone ( ) . hours ( 23 ) . minutes ( 59 ) . seconds ( 59 ) ;
4442 const whatsAppHttpClientInstance = new HttpClientUtil . HttpClient ( ) ;
45- const startDateFormattation = startDate . clone ( ) . format ( 'DD/MM/YYYY HH:mm:ss' ) ;
46- const endDateFormattation = endDate . clone ( ) . format ( 'DD/MM/YYYY HH:mm:ss' ) ;
43+ const startDateFormattation = date . hours ( ) < 12 ? date . clone ( ) . hours ( 0 ) . minutes ( 0 ) . seconds ( 0 ) . format ( 'DD/MM/YYYY HH:mm:ss' ) : date . clone ( ) . hours ( 12 ) . minutes ( 0 ) . seconds ( 0 ) . format ( 'DD/MM/YYYY HH:mm:ss' ) ;
44+ const endDateFormattation = date . hours ( ) < 12 ? date . clone ( ) . hours ( 11 ) . minutes ( 59 ) . seconds ( 59 ) . format ( 'DD/MM/YYYY HH:mm:ss' ) : date . clone ( ) . hours ( 23 ) . minutes ( 59 ) . seconds ( 59 ) . format ( 'DD/MM/YYYY HH:mm:ss' ) ;
4745
4846 Promise . allSettled (
4947 alertMapListA . map (
@@ -55,10 +53,11 @@ export const createAlerts = async (): Promise<void> => {
5553 const fenceTrackerRegister = await prisma . fence_tracker_registers . findUnique (
5654 {
5755 where : {
58- account_code_period_started_at_period_ended_at : {
56+ account_code_zone_name_period_started_at_period_ended_at : {
5957 account_code : alertMapAccountCode ,
60- period_started_at : startDate . toDate ( ) ,
61- period_ended_at : endDate . toDate ( )
58+ zone_name : alertMapZoneName ,
59+ period_started_at : date . hours ( ) < 12 ? date . clone ( ) . hours ( 0 ) . minutes ( 0 ) . seconds ( 0 ) . toDate ( ) : date . clone ( ) . hours ( 12 ) . minutes ( 0 ) . seconds ( 0 ) . toDate ( ) ,
60+ period_ended_at : date . hours ( ) < 12 ? date . clone ( ) . hours ( 11 ) . minutes ( 59 ) . seconds ( 59 ) . toDate ( ) : date . clone ( ) . hours ( 23 ) . minutes ( 59 ) . seconds ( 59 ) . toDate ( )
6261 }
6362 }
6463 }
@@ -75,8 +74,8 @@ export const createAlerts = async (): Promise<void> => {
7574 cabinet : alertMap . cabinet ,
7675 zone_name : alertMapZoneName ,
7776 quantity : alertMapQuantityMultiple ,
78- period_started_at : startDate . toDate ( ) ,
79- period_ended_at : endDate . toDate ( )
77+ period_started_at : date . hours ( ) < 12 ? date . clone ( ) . hours ( 0 ) . minutes ( 0 ) . seconds ( 0 ) . toDate ( ) : date . clone ( ) . hours ( 12 ) . minutes ( 0 ) . seconds ( 0 ) . toDate ( ) ,
78+ period_ended_at : date . hours ( ) < 12 ? date . clone ( ) . hours ( 11 ) . minutes ( 59 ) . seconds ( 59 ) . toDate ( ) : date . clone ( ) . hours ( 23 ) . minutes ( 59 ) . seconds ( 59 ) . toDate ( )
8079 }
8180 }
8281 ) ;
0 commit comments