@@ -275,67 +275,78 @@ export class EmailService {
275
275
event . eventName ,
276
276
) ;
277
277
if ( triggeredLeadTimes [ leadTime . leadTimeName ] === '1' ) {
278
- // .. find the right leadtime
279
- const [ leadTimeValue , leadTimeUnit ] = leadTime . leadTimeLabel . split (
280
- '-' ,
281
- ) ;
282
-
283
- const eventName = event . eventName
284
- ? `${ event . eventName } `
285
- : this . notificationContentService . firstCharOfWordsToUpper (
286
- (
287
- await this . notificationContentService . getDisaster (
288
- disasterType ,
289
- )
290
- ) . label ,
291
- ) ;
292
-
293
- const triggerStatus = event . thresholdReached
294
- ? 'trigger reached'
295
- : 'trigger not reached' ;
296
-
297
- const dateTimePreposition = leadTimeUnit === 'month' ? 'in' : 'on' ;
298
- const dateAndTime = this . notificationContentService . getFirstLeadTimeDate (
299
- Number ( leadTimeValue ) ,
300
- leadTimeUnit ,
301
- ) ;
302
- const disasterSpecificCopy = await this . getDisasterSpecificCopy (
303
- disasterType ,
304
- leadTime ,
305
- event ,
306
- ) ;
307
- const leadTimeFromNow = `${ leadTimeValue } ${ leadTimeUnit } s` ;
308
-
309
278
// We are hack-misusing 'extraInfo' being filled as a proxy for typhoonNoLandfallYet-boolean
310
- const leadTimeString = disasterSpecificCopy . leadTimeString
311
- ? disasterSpecificCopy . leadTimeString
312
- : leadTimeFromNow ;
313
-
314
- const timestamp = disasterSpecificCopy . timestamp
315
- ? ` | ${ disasterSpecificCopy . timestamp } `
316
- : '' ;
317
-
318
- leadTimeListShort = `${ leadTimeListShort } <li>${ eventName } : ${
319
- disasterSpecificCopy . extraInfo ||
320
- leadTime . leadTimeName === LeadTime . hour0
321
- ? leadTimeString
322
- : `${ dateAndTime } ${ timestamp } (${ leadTimeString } )`
279
+ leadTimeListShort = `${ leadTimeListShort } <li>${
280
+ ( await this . getLeadTimeListEvent ( event , disasterType , leadTime ) )
281
+ . short
282
+ } </li>`;
283
+ leadTimeListLong = `${ leadTimeListLong } <li>${
284
+ ( await this . getLeadTimeListEvent ( event , disasterType , leadTime ) )
285
+ . long
323
286
} </li>`;
324
- leadTimeListLong = `${ leadTimeListLong } <li>${ eventName } - <strong>${ triggerStatus } </strong>: ${
325
- disasterSpecificCopy . eventStatus
326
- } ${
327
- disasterSpecificCopy . extraInfo ||
328
- leadTime . leadTimeName === LeadTime . hour0
329
- ? ''
330
- : ` ${ dateTimePreposition } ${ dateAndTime } ${ timestamp } (${ leadTimeString } )`
331
- } . ${ disasterSpecificCopy . extraInfo } </li>`;
332
287
}
333
288
}
334
289
}
335
290
}
336
291
return { leadTimeListShort, leadTimeListLong } ;
337
292
}
338
293
294
+ private async getLeadTimeListEvent (
295
+ event : EventSummaryCountry ,
296
+ disasterType : DisasterType ,
297
+ leadTime : any ,
298
+ ) {
299
+ // .. find the right leadtime
300
+ const [ leadTimeValue , leadTimeUnit ] = leadTime . leadTimeLabel . split ( '-' ) ;
301
+
302
+ const eventName = event . eventName
303
+ ? `${ event . eventName } `
304
+ : this . notificationContentService . firstCharOfWordsToUpper (
305
+ ( await this . notificationContentService . getDisaster ( disasterType ) )
306
+ . label ,
307
+ ) ;
308
+
309
+ const triggerStatus = event . thresholdReached
310
+ ? 'trigger reached'
311
+ : 'trigger not reached' ;
312
+
313
+ const dateTimePreposition = leadTimeUnit === 'month' ? 'in' : 'on' ;
314
+ const dateAndTime = this . notificationContentService . getFirstLeadTimeDate (
315
+ Number ( leadTimeValue ) ,
316
+ leadTimeUnit ,
317
+ ) ;
318
+ const disasterSpecificCopy = await this . getDisasterSpecificCopy (
319
+ disasterType ,
320
+ leadTime ,
321
+ event ,
322
+ ) ;
323
+ const leadTimeFromNow = `${ leadTimeValue } ${ leadTimeUnit } s` ;
324
+
325
+ const leadTimeString = disasterSpecificCopy . leadTimeString
326
+ ? disasterSpecificCopy . leadTimeString
327
+ : leadTimeFromNow ;
328
+
329
+ const timestamp = disasterSpecificCopy . timestamp
330
+ ? ` | ${ disasterSpecificCopy . timestamp } `
331
+ : '' ;
332
+ return {
333
+ short : `${ eventName } : ${
334
+ disasterSpecificCopy . extraInfo ||
335
+ leadTime . leadTimeName === LeadTime . hour0
336
+ ? leadTimeString
337
+ : `${ dateAndTime } ${ timestamp } (${ leadTimeString } )`
338
+ } `,
339
+ long : `${ eventName } - <strong>${ triggerStatus } </strong>: ${
340
+ disasterSpecificCopy . eventStatus
341
+ } ${
342
+ disasterSpecificCopy . extraInfo ||
343
+ leadTime . leadTimeName === LeadTime . hour0
344
+ ? ''
345
+ : ` ${ dateTimePreposition } ${ dateAndTime } ${ timestamp } (${ leadTimeString } )`
346
+ } . ${ disasterSpecificCopy . extraInfo } `,
347
+ } ;
348
+ }
349
+
339
350
private async getTriggerOverviewTables (
340
351
country : CountryEntity ,
341
352
disasterType : DisasterType ,
@@ -466,24 +477,11 @@ export class EmailService {
466
477
name : ( await this . notificationContentService . getDisaster ( disasterType ) )
467
478
. actionsUnit ,
468
479
} ) ;
469
- const leadTimeValue = leadTime . leadTimeName . split ( '-' ) [ 0 ] ;
470
- const leadTimeUnit = leadTime . leadTimeName . split ( '-' ) [ 1 ] ;
471
-
472
- const zeroHour = leadTime . leadTimeName === LeadTime . hour0 ;
473
- const disasterSpecificCopy = this . getDisasterSpecificCopy (
474
- disasterType ,
475
- leadTime ,
476
- event ,
477
- ) ;
478
480
479
481
const tableForLeadTimeStart = `<div>
480
482
<strong>${
481
- zeroHour
482
- ? disasterSpecificCopy
483
- : `Forecast ${
484
- disasterType === DisasterType . HeavyRain ? 'estimated ' : ''
485
- } ${ leadTimeValue } ${ leadTimeUnit } (s) from`
486
- } today (${ this . placeholderToday } ):</strong>
483
+ ( await this . getLeadTimeListEvent ( event , disasterType , leadTime ) ) . short
484
+ } </strong>
487
485
</div>
488
486
<table class="notification-alerts-table">
489
487
<caption class="notification-alerts-table-caption">The following table lists all the exposed ${ adminAreaLabels . plural . toLowerCase ( ) } in order of ${ actionUnit . label . toLowerCase ( ) } ,</caption>
0 commit comments