File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -530,16 +530,23 @@ private static function save_snapshots( array $snapshots )
530530
531531 global $ wpdb ;
532532 $ table_name = $ wpdb ->prefix . self ::$ table_name ;
533- $ now = ( new DateTime () )-> format ( ' Y-m-d H:i:s ' );
533+ $ now = new DateTime ();
534534
535535 $ logged_data = false ;
536+ $ counter = 0 ;
536537 foreach ( $ filtered_snapshots as $ snapshot ) {
537538 if ( empty ( $ snapshot ['post_id ' ] ) || empty ( $ snapshot ['post_type ' ] )
538539 || empty ( $ snapshot ['period ' ] ) || empty ( $ snapshot ['period_start ' ] )
539540 || empty ( $ snapshot ['period_end ' ] ) || empty ( $ snapshot ['period_interval ' ] ) ) {
540541 continue ;
541542 }
542543
544+ $ snapshot_date = clone $ now ;
545+ if ( $ counter >= 50 ) {
546+ $ seconds_to_subtract = floor ( $ counter / 50 );
547+ $ snapshot_date ->modify ( "- $ seconds_to_subtract seconds " );
548+ }
549+
543550 $ data = [
544551 'post_id ' => $ snapshot ['post_id ' ],
545552 'post_type ' => $ snapshot ['post_type ' ],
@@ -549,8 +556,9 @@ private static function save_snapshots( array $snapshots )
549556 'period_end ' => $ snapshot ['period_end ' ]->format ( 'Y-m-d H:i:s ' ),
550557 'period_interval ' => $ snapshot ['period_interval ' ],
551558 'post_content ' => wp_json_encode ( $ snapshot ['post_content ' ] ?? [] ),
552- 'snapshot_date ' => $ now
559+ 'snapshot_date ' => $ snapshot_date -> format ( ' Y-m-d H:i:s ' )
553560 ];
561+ $ counter ++;
554562 if ( !$ logged_data ) {
555563// dt_write_log( 'Saving data: ' . json_encode( $data ) );
556564 $ logged_data = true ;
You can’t perform that action at this time.
0 commit comments