@@ -294,6 +294,15 @@ private function store_transactions( $page ) {
294294 $ tr ['credit_amounts ' ],
295295 $ tr ['debit_amounts ' ]
296296 );
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+
297306 }
298307
299308 return $ page + 1 ;
@@ -400,12 +409,25 @@ private function store_tasks( $filter, $page ) {
400409 } elseif ( ! empty ( $ task ['last_event ' ]['object ' ]['published_at ' ] ) ) {
401410 $ new_task ['last_activity ' ] = (int ) $ task ['last_event ' ]['object ' ]['published_at ' ];
402411 $ 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 ' ] = '' ;
403419 }
404420
421+
405422 if ( ! empty ( $ task ['last_event ' ]['user ' ]['full_name ' ] ) ) {
406423 $ new_task ['last_activity_by ' ] = $ task ['last_event ' ]['user ' ]['full_name ' ];
407424 }
408425
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+
409431 // Some simple rules to automatically detect the correct flag for tasks.
410432 if ( 'canceled ' === $ task ['state ' ] ) {
411433 // Tasks that were canceled by the client obviously are lost.
0 commit comments