@@ -294,6 +294,15 @@ private function store_transactions( $page ) {
294
294
$ tr ['credit_amounts ' ],
295
295
$ tr ['debit_amounts ' ]
296
296
);
297
+
298
+ // If we find a transaction that already exists, bail out and don't continue updating all the transactions
299
+ if ( $ exists ) {
300
+ update_option ( 'wpcable_average ' , $ single_page ['average_task_size ' ] );
301
+ update_option ( 'wpcable_balance ' , $ single_page ['balance ' ] );
302
+ update_option ( 'wpcable_revenue ' , $ single_page ['revenue ' ] );
303
+ return false ;
304
+ }
305
+
297
306
}
298
307
299
308
return $ page + 1 ;
@@ -400,12 +409,25 @@ private function store_tasks( $filter, $page ) {
400
409
} elseif ( ! empty ( $ task ['last_event ' ]['object ' ]['published_at ' ] ) ) {
401
410
$ new_task ['last_activity ' ] = (int ) $ task ['last_event ' ]['object ' ]['published_at ' ];
402
411
$ new_task ['last_activity_by ' ] = '' ;
412
+ }elseif ( ! empty ( $ task ['last_event ' ]['object ' ]['created_at ' ] ) ) {
413
+ $ new_task ['last_activity ' ] = (int ) strtotime ($ task ['last_event ' ]['object ' ]['created_at ' ]);
414
+ $ new_task ['last_activity_by ' ] = '' ;
415
+ }
416
+ elseif ( ! empty ( $ task ['last_event ' ]['object ' ]['updated_at ' ] ) ) {
417
+ $ new_task ['last_activity ' ] = (int ) strtotime ($ task ['last_event ' ]['object ' ]['updated_at ' ]);
418
+ $ new_task ['last_activity_by ' ] = '' ;
403
419
}
404
420
421
+
405
422
if ( ! empty ( $ task ['last_event ' ]['user ' ]['full_name ' ] ) ) {
406
423
$ new_task ['last_activity_by ' ] = $ task ['last_event ' ]['user ' ]['full_name ' ];
407
424
}
408
425
426
+ if ( ! empty ( $ task ['last_event ' ]['type ' ]) && 'create_vault ' === $ task ['last_event ' ]['type ' ]) {
427
+ $ new_task ['last_activity ' ] = (int ) strtotime ($ task ['last_event ' ]['user ' ]['last_sign_in_at ' ]);
428
+ $ new_task ['last_activity_by ' ] = $ task ['last_event ' ]['user ' ]['full_name ' ];
429
+ }
430
+
409
431
// Some simple rules to automatically detect the correct flag for tasks.
410
432
if ( 'canceled ' === $ task ['state ' ] ) {
411
433
// Tasks that were canceled by the client obviously are lost.
0 commit comments