feat(import): store primary destination; crawl configured cities

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-29 15:20:29 +03:30
parent 614ea98825
commit 02b6ce0ff4
4 changed files with 16 additions and 6 deletions

View File

@@ -156,10 +156,14 @@ class VC_Cron {
$map = get_transient( 'vc_destination_map' );
// A destination allowlist (comma-separated IDs) narrows the crawl to a
// focused set; empty means the whole catalogue.
$allow = array_filter( array_map( 'trim', explode( ',', (string) vc_get_option( 'crawl_destinations', '' ) ) ) );
if ( ! empty( $allow ) ) {
// Cities configured on the Viator Structure screen define the crawl.
// Without any, a destination allowlist (comma-separated IDs) narrows
// the crawl to a focused set; empty means the whole catalogue.
$cities = array_map( 'strval', array_keys( VC_Structure::cities( VC_Structure::get() ) ) );
$allow = array_filter( array_map( 'trim', explode( ',', (string) vc_get_option( 'crawl_destinations', '' ) ) ) );
if ( ! empty( $cities ) ) {
$queue = $cities;
} elseif ( ! empty( $allow ) ) {
$queue = array_values( array_unique( $allow ) );
} else {
$queue = is_array( $map ) ? array_keys( $map ) : array();
@@ -191,7 +195,11 @@ class VC_Cron {
);
update_option( 'vc_ingest_in_progress', 1, false );
update_option( 'vc_last_sync_started_at', current_time( 'mysql' ), false );
VC_Logger::info( sprintf( 'Sync run started — %d destinations queued.', count( $queue ) ) );
if ( ! empty( $cities ) ) {
VC_Logger::info( sprintf( 'Sync run started from structure — %d cities queued.', count( $queue ) ) );
} else {
VC_Logger::info( sprintf( 'Sync run started — %d destinations queued.', count( $queue ) ) );
}
return true;
}