@@ -29,30 +29,20 @@ const TRIGGER_BY_EVENT = Object.keys(commonLib.TRIGGERED_BY_EVENT).map(name => (
2929 * Takes the timezone offset into account while calculating the trigger time.
3030 * @param {string } period - "hourly"|"daily"|"monthly"
3131 * @param {number } offset - timezone offset in minutes
32- * @returns {string|undefined } schedule text
32+ * @returns {string } schedule text
3333 */
3434function getScheduleTextExpression ( period , offset ) {
35- if ( typeof offset !== "number" ) {
36- log . e ( "Offset is required" ) ;
37- return ;
38- }
3935 if ( period === "hourly" ) {
4036 return "every 1 hour on the 59th min" ;
4137 }
42- else {
43- const utcClock = moment ( "2026-02-01T23:59:00.000Z" )
44- . tz ( "UTC" )
45- . subtract ( offset , "minutes" )
46- . format ( "HH:mm" ) ;
47- if ( period === "daily" ) {
48- return "at " + utcClock ;
49- }
50- else if ( period === "monthly" ) {
51- return "on the last day of the month at " + utcClock ;
52- }
38+ const utcClock = moment ( "2026-02-01T23:59:00.000Z" )
39+ . tz ( "UTC" )
40+ . subtract ( offset , "minutes" )
41+ . format ( "HH:mm" ) ;
42+ if ( period === "daily" ) {
43+ return "at " + utcClock ;
5344 }
54- log . e ( `No such period \"${ period } \"` ) ;
55- return ;
45+ return "on the last day of the month at " + utcClock ;
5646}
5747
5848( function ( ) {
@@ -81,7 +71,7 @@ function getScheduleTextExpression(period, offset) {
8171 * @param {object } alert - alert record data
8272 */
8373 async function updateJobForAlert ( alert ) {
84- if ( alert . enabled ) {
74+ if ( alert . enabled && Object . keys ( commonLib . PERIOD_TO_DATE_COMPONENT_MAP ) . includes ( alert . period ) ) {
8575 const apps = await commonLib . loadAlertAppsWithTimezoneOffsets ( alert ) ;
8676 for ( const app of apps ) {
8777 const textExpression = getScheduleTextExpression ( alert . period , app . offset ) ;
@@ -289,13 +279,13 @@ function getScheduleTextExpression(period, offset) {
289279
290280
291281 /**
292- * @api {get } /i/alert/delete delete alert by alert ID
293- * @apiName deleteAlert
294- * @apiGroup alerts
282+ * @api {get } /i/alert/delete delete alert by alert ID
283+ * @apiName deleteAlert
284+ * @apiGroup alerts
295285 *
296286 * @apiDescription delete alert by id.
297287 * @apiQuery {string} alertID target alert id from db.
298- * @apiQuery {String} app_id target app id of the alert.
288+ * @apiQuery {String} app_id target app id of the alert.
299289 *
300290 * @apiSuccessExample {json} Success-Response:
301291 * HTTP/1.1 200 OK
@@ -343,13 +333,13 @@ function getScheduleTextExpression(period, offset) {
343333
344334 /**
345335 * @api {post } /i/alert/status change alert status
346- * @apiName changeAlertStatus
347- * @apiGroup alerts
336+ * @apiName changeAlertStatus
337+ * @apiGroup alerts
348338 *
349339 * @apiDescription change alerts status by boolean flag.
350340 * @apiQuery {string} JSON string of status object for alerts record want to update.
351341 * for example: {"626270afbf7392a8bfd8c1f3":false, "42dafbf7392a8bfd8c1e1": true}
352- * @apiQuery {String} app_id target app id of the alert.
342+ * @apiQuery {String} app_id target app id of the alert.
353343 *
354344 * @apiSuccessExample {text} Success-Response:
355345 * HTTP/1.1 200 OK
0 commit comments