@@ -212,12 +212,10 @@ public function addRule(array $config): int
212
212
213
213
$ db ->beginTransaction ();
214
214
215
- $ changedAt = time () * 1000 ;
216
215
$ db ->insert ('rule ' , [
217
216
'name ' => $ config ['name ' ],
218
217
'timeperiod_id ' => $ config ['timeperiod_id ' ] ?? null ,
219
- 'object_filter ' => $ config ['object_filter ' ] ?? null ,
220
- 'changed_at ' => $ changedAt
218
+ 'object_filter ' => $ config ['object_filter ' ] ?? null
221
219
]);
222
220
$ ruleId = $ db ->lastInsertId ();
223
221
@@ -227,16 +225,14 @@ public function addRule(array $config): int
227
225
'position ' => $ position ,
228
226
'condition ' => $ escalationConfig ['condition ' ] ?? null ,
229
227
'name ' => $ escalationConfig ['name ' ] ?? null ,
230
- 'fallback_for ' => $ escalationConfig ['fallback_for ' ] ?? null ,
231
- 'changed_at ' => $ changedAt
228
+ 'fallback_for ' => $ escalationConfig ['fallback_for ' ] ?? null
232
229
]);
233
230
$ escalationId = $ db ->lastInsertId ();
234
231
235
232
foreach ($ escalationConfig ['recipient ' ] ?? [] as $ recipientConfig ) {
236
233
$ data = [
237
234
'rule_escalation_id ' => $ escalationId ,
238
- 'channel_id ' => $ recipientConfig ['channel_id ' ],
239
- 'changed_at ' => $ changedAt
235
+ 'channel_id ' => $ recipientConfig ['channel_id ' ]
240
236
];
241
237
242
238
switch (true ) {
@@ -272,16 +268,14 @@ public function addRule(array $config): int
272
268
*/
273
269
private function insertOrUpdateEscalations ($ ruleId , array $ escalations , Connection $ db , bool $ insert = false ): void
274
270
{
275
- $ changedAt = time () * 1000 ;
276
271
foreach ($ escalations as $ position => $ escalationConfig ) {
277
272
if ($ insert ) {
278
273
$ db ->insert ('rule_escalation ' , [
279
274
'rule_id ' => $ ruleId ,
280
275
'position ' => $ position ,
281
276
'condition ' => $ escalationConfig ['condition ' ] ?? null ,
282
277
'name ' => $ escalationConfig ['name ' ] ?? null ,
283
- 'fallback_for ' => $ escalationConfig ['fallback_for ' ] ?? null ,
284
- 'changed_at ' => $ changedAt
278
+ 'fallback_for ' => $ escalationConfig ['fallback_for ' ] ?? null
285
279
]);
286
280
287
281
$ escalationId = $ db ->lastInsertId ();
@@ -291,8 +285,7 @@ private function insertOrUpdateEscalations($ruleId, array $escalations, Connecti
291
285
'position ' => $ position ,
292
286
'condition ' => $ escalationConfig ['condition ' ] ?? null ,
293
287
'name ' => $ escalationConfig ['name ' ] ?? null ,
294
- 'fallback_for ' => $ escalationConfig ['fallback_for ' ] ?? null ,
295
- 'changed_at ' => $ changedAt
288
+ 'fallback_for ' => $ escalationConfig ['fallback_for ' ] ?? null
296
289
], ['id = ? ' => $ escalationId , 'rule_id = ? ' => $ ruleId ]);
297
290
$ recipientsToRemove = [];
298
291
@@ -318,7 +311,7 @@ function (array $element) use ($recipientId) {
318
311
if (! empty ($ recipientsToRemove )) {
319
312
$ db ->update (
320
313
'rule_escalation_recipient ' ,
321
- ['changed_at ' => $ changedAt , ' deleted ' => 'y ' ],
314
+ ['deleted ' => 'y ' ],
322
315
['id IN (?) ' => $ recipientsToRemove , 'deleted = ? ' => 'n ' ]
323
316
);
324
317
}
@@ -327,8 +320,7 @@ function (array $element) use ($recipientId) {
327
320
foreach ($ escalationConfig ['recipient ' ] ?? [] as $ recipientConfig ) {
328
321
$ data = [
329
322
'rule_escalation_id ' => $ escalationId ,
330
- 'channel_id ' => $ recipientConfig ['channel_id ' ],
331
- 'changed_at ' => $ changedAt
323
+ 'channel_id ' => $ recipientConfig ['channel_id ' ]
332
324
];
333
325
334
326
switch (true ) {
@@ -353,9 +345,7 @@ function (array $element) use ($recipientId) {
353
345
$ db ->insert ('rule_escalation_recipient ' , $ data );
354
346
} else {
355
347
$ db ->update (
356
- 'rule_escalation_recipient ' ,
357
- $ data + ['changed_at ' => $ changedAt ],
358
- ['id = ? ' => $ recipientConfig ['id ' ]]
348
+ 'rule_escalation_recipient ' , $ data , ['id = ? ' => $ recipientConfig ['id ' ]] //TODO:TEST, need deleted flag check
359
349
);
360
350
}
361
351
}
@@ -390,9 +380,8 @@ public function editRule(int $id, array $config): void
390
380
$ data ['object_filter ' ] = $ values ['object_filter ' ];
391
381
}
392
382
393
- $ changedAt = time () * 1000 ;
394
383
if (! empty ($ data )) {
395
- $ db ->update ('rule ' , $ data + [ ' changed_at ' => $ changedAt ] , ['id = ? ' => $ id ]);
384
+ $ db ->update ('rule ' , $ data , ['id = ? ' => $ id ]);
396
385
}
397
386
398
387
if (! isset ($ values ['rule_escalation ' ])) {
@@ -426,7 +415,7 @@ public function editRule(int $id, array $config): void
426
415
// Escalations to add
427
416
$ escalationsToAdd = $ escalationsInCache ;
428
417
429
- $ markAsDeleted = ['changed_at ' => $ changedAt , ' deleted ' => 'y ' ];
418
+ $ markAsDeleted = ['deleted ' => 'y ' ];
430
419
if (! empty ($ escalationsToRemove )) {
431
420
$ db ->update (
432
421
'rule_escalation_recipient ' ,
@@ -472,7 +461,7 @@ public function removeRule(int $id): void
472
461
->assembleSelect ()
473
462
);
474
463
475
- $ markAsDeleted = ['changed_at ' => time () * 1000 , ' deleted ' => 'y ' ];
464
+ $ markAsDeleted = ['deleted ' => 'y ' ];
476
465
if (! empty ($ escalationsToRemove )) {
477
466
$ db ->update (
478
467
'rule_escalation_recipient ' ,
0 commit comments