__( 'Small signals (scroll, tab and click events)', 'ai-eshop-optimizer' ), 'journeys' => __( 'Visits to pages, products and categories, and searches', 'ai-eshop-optimizer' ), 'commerce' => __( 'Cart, checkout and purchase events', 'ai-eshop-optimizer' ), 'visits' => __( 'Visit summaries', 'ai-eshop-optimizer' ), 'reco' => __( 'Recommendation views and clicks', 'ai-eshop-optimizer' ), 'intent' => __( 'Shop filter events (filters, sorts and views on product lists)', 'ai-eshop-optimizer' ), ); $aieo_ds_presets = array( 'lean' => __( 'Lean', 'ai-eshop-optimizer' ), 'balanced' => __( 'Balanced', 'ai-eshop-optimizer' ), 'full' => __( 'Full', 'ai-eshop-optimizer' ), 'custom' => __( 'My own days', 'ai-eshop-optimizer' ), ); $aieo_ds_form = 'aieo-retention-form'; list( $aieo_ds_open, $aieo_ds_close ) = AIEO_DMM_UI::card( array( 'anchor' => 'db-performance-event-data', 'icon' => 'calendar-clock', 'title' => __( 'Event data: how long it is kept', 'ai-eshop-optimizer' ), 'description' => __( 'How long the record of what visitors do is kept, kind by kind. Old events are deleted only after the nightly summaries have counted them; the summaries per product, customer and visitor are kept for good.', 'ai-eshop-optimizer' ), 'col' => 1, 'footer' => class_exists( '\Rooster\Admin\States' ) ? \Rooster\Admin\States::save_button( $aieo_ds_form ) : '', ) ); echo $aieo_ds_open; ob_start(); echo '
'; foreach ( $aieo_ds_presets as $aieo_ds_value => $aieo_ds_label ) { echo ''; } echo '
'; echo '
'; foreach ( $aieo_ds_kinds as $aieo_ds_kind => $aieo_ds_label ) { echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-retention-days-' . $aieo_ds_kind, 'label' => $aieo_ds_label, 'control' => \Rooster\Admin\Ui::input( 'days_' . $aieo_ds_kind, (string) (int) $aieo_ds_settings['days'][ $aieo_ds_kind ], array( 'id' => 'aieo-retention-days-' . $aieo_ds_kind, 'type' => 'number', 'xs' => true, 'min' => AIEO_Data_Retention::FLOORS[ $aieo_ds_kind ], 'max' => 3650, 'unit' => __( 'days', 'ai-eshop-optimizer' ) ) ), 'help' => sprintf( __( 'At least %d days, so every nightly summary can count them first.', 'ai-eshop-optimizer' ), AIEO_Data_Retention::FLOORS[ $aieo_ds_kind ] ), ) ); } echo '
'; $aieo_ds_hours = array(); for ( $aieo_ds_h = 0; $aieo_ds_h < 24; $aieo_ds_h++ ) { $aieo_ds_hours[ (string) $aieo_ds_h ] = sprintf( '%02d:%02d GMT', $aieo_ds_h, AIEO_Data_Retention::MINUTE ); } echo \Rooster\Admin\Ui::field_row( array( 'id' => 'aieo-retention-hour', 'label' => __( 'Daily clean-up at', 'ai-eshop-optimizer' ), 'control' => \Rooster\Admin\Ui::select( 'hour', $aieo_ds_hours, (string) $aieo_ds_settings['hour'], array( 'id' => 'aieo-retention-hour', 'short' => true ) ), 'help' => __( 'After the nightly summaries and the move of old events to their archives. Pick a quiet hour for your shop.', 'ai-eshop-optimizer' ), ) ); echo AIEO_DMM_UI::card_form( 'aieo_dmm_retention_save', 'db_performance', $aieo_ds_form, (string) ob_get_clean() ); echo '

' . esc_html__( 'What the next clean-up does', 'ai-eshop-optimizer' ) . '

'; $aieo_ds_last = ''; if ( ! empty( $aieo_ds_state['finished'] ) ) { $aieo_ds_total = 0; foreach ( (array) ( $aieo_ds_state['targets'] ?? array() ) as $aieo_ds_t ) { $aieo_ds_total += (int) ( $aieo_ds_t['deleted'] ?? 0 ); } $aieo_ds_last = sprintf( __( 'Last clean-up %1$s GMT: %2$s old rows deleted.', 'ai-eshop-optimizer' ), $aieo_ds_state['finished'], number_format_i18n( $aieo_ds_total ) ); } echo \Rooster\Admin\States::job( array( 'id' => 'aieo-retention-job', 'state' => 'idle', 'run' => __( 'Clean up now', 'ai-eshop-optimizer' ), 'primary' => false, 'run_attrs' => array( 'id' => 'aieo-retention-run' ), 'last' => $aieo_ds_last, 'detail' => '', ) ); echo $aieo_ds_close; $aieo_ds_rform = 'aieo-reclaim-form'; $aieo_ds_why = AIEO_Space_Reclaim::unavailable(); list( $aieo_ds_open, $aieo_ds_close ) = AIEO_DMM_UI::card( array( 'anchor' => 'db-performance-disk-space', 'icon' => 'database', 'title' => __( 'Disk space', 'ai-eshop-optimizer' ), 'description' => __( 'Deleted rows leave their space inside a table for its next rows. Rebuilding the table gives it back to the disk, while the shop goes on reading and writing it. Tables the nightly jobs rebuild themselves are left alone.', 'ai-eshop-optimizer' ), 'col' => 2, 'footer' => '' === $aieo_ds_why && class_exists( '\Rooster\Admin\States' ) ? \Rooster\Admin\States::save_button( $aieo_ds_rform ) : '', ) ); echo $aieo_ds_open; if ( '' !== $aieo_ds_why ) { echo \Rooster\Admin\States::state( 'not-set-up', array( 'title' => $aieo_ds_why, 'compact' => true ) ); } else { $aieo_ds_list = AIEO_Space_Reclaim::candidates(); if ( $aieo_ds_list ) { echo '

' . esc_html__( 'Space worth giving back', 'ai-eshop-optimizer' ) . '

'; } else { echo '

' . esc_html( sprintf( __( 'No table has %d MB or more to give back now.', 'ai-eshop-optimizer' ), AIEO_Space_Reclaim::MIN_FREE_MB ) ) . '

'; } ob_start(); echo '
'; foreach ( array( 'off' => __( 'Only when I ask', 'ai-eshop-optimizer' ), 'weekly' => __( 'Every week', 'ai-eshop-optimizer' ), 'monthly' => __( 'Every month', 'ai-eshop-optimizer' ), ) as $aieo_ds_value => $aieo_ds_label ) { echo ''; } echo '
'; echo AIEO_DMM_UI::card_form( 'aieo_dmm_reclaim_save', 'db_performance', $aieo_ds_rform, (string) ob_get_clean() ); echo \Rooster\Admin\States::job( array( 'id' => 'aieo-reclaim-job', 'state' => 'idle', 'run' => __( 'Give space back now', 'ai-eshop-optimizer' ), 'primary' => false, 'run_attrs' => array( 'id' => 'aieo-reclaim-run' ), 'detail' => '', ) ); } echo $aieo_ds_close;