Skip to content

Commit add55cd

Browse files
committed
fix: remove hardcoded location taxonomy from CLI config summary
Both extractPipelineLocation and extractConfigSummary were calling get_term() with hardcoded 'location' taxonomy. Data Machine core must not be aware of Extra Chill-level taxonomies. Replaced with domain-agnostic approach: reads raw config values (coordinates, city, URLs, venue_name) and iterates any taxonomy_*_selection keys generically.
1 parent 54b3a8e commit add55cd

2 files changed

Lines changed: 67 additions & 91 deletions

File tree

inc/Cli/Commands/Flows/FlowsCommand.php

Lines changed: 43 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -895,12 +895,9 @@ private function extractHandlers( array $flow ): string {
895895
/**
896896
* Extract a concise config summary from flow handler configs.
897897
*
898-
* Shows the key distinguishing config per handler type:
899-
* - ticketmaster: coordinates + radius
900-
* - dice_fm: city name
901-
* - universal_web_scraper / web_scraper: source URL or venue name
902-
* - rss: feed URL
903-
* - upsert_event: location taxonomy term
898+
* Domain-agnostic: reads raw config values without assuming any
899+
* specific taxonomy, handler, or post type. Surfaces distinguishing
900+
* values like coordinates, city names, URLs, and taxonomy selections.
904901
*
905902
* @param array $flow Flow data.
906903
* @return string Config summary (max ~60 chars).
@@ -912,62 +909,55 @@ private function extractConfigSummary( array $flow ): string {
912909
foreach ( $flow_config as $step_data ) {
913910
$handler_configs = $step_data['handler_configs'] ?? array();
914911

915-
foreach ( $handler_configs as $handler_slug => $hconfig ) {
916-
switch ( $handler_slug ) {
917-
case 'ticketmaster':
918-
$loc = $hconfig['location'] ?? '';
919-
$rad = $hconfig['radius'] ?? '';
920-
if ( $loc ) {
921-
$parts[] = $loc . ( $rad ? " r={$rad}" : '' );
922-
}
923-
break;
912+
foreach ( $handler_configs as $hconfig ) {
913+
if ( ! is_array( $hconfig ) ) {
914+
continue;
915+
}
924916

925-
case 'dice_fm':
926-
$city = $hconfig['city'] ?? '';
927-
if ( $city ) {
928-
$parts[] = "city={$city}";
929-
}
930-
break;
931-
932-
case 'universal_web_scraper':
933-
case 'web_scraper':
934-
$url = $hconfig['source_url'] ?? '';
935-
$name = $hconfig['venue_name'] ?? '';
936-
if ( $name ) {
937-
$parts[] = $name;
938-
} elseif ( $url ) {
939-
// Show just the domain.
940-
$host = wp_parse_url( $url, PHP_URL_HOST );
941-
$parts[] = $host ?: $url;
942-
}
943-
break;
917+
// Coordinates (location field with lat,lon).
918+
if ( ! empty( $hconfig['location'] ) && strpos( $hconfig['location'], ',' ) !== false ) {
919+
$loc = $hconfig['location'];
920+
$rad = $hconfig['radius'] ?? '';
921+
$parts[] = $loc . ( $rad ? " r={$rad}" : '' );
922+
}
944923

945-
case 'rss':
946-
$url = $hconfig['feed_url'] ?? $hconfig['url'] ?? '';
947-
if ( $url ) {
948-
$host = wp_parse_url( $url, PHP_URL_HOST );
949-
$parts[] = $host ?: $url;
950-
}
951-
break;
952-
953-
case 'upsert_event':
954-
$loc_term = $hconfig['taxonomy_location_selection'] ?? '';
955-
if ( $loc_term && is_numeric( $loc_term ) ) {
956-
$term = get_term( (int) $loc_term, 'location' );
957-
if ( $term && ! is_wp_error( $term ) ) {
958-
$parts[] = "loc={$term->name}";
959-
}
960-
} elseif ( $loc_term && 'skip' !== $loc_term && 'ai_decides' !== $loc_term ) {
961-
$parts[] = "loc={$loc_term}";
924+
// City name.
925+
if ( ! empty( $hconfig['city'] ) ) {
926+
$parts[] = "city={$hconfig['city']}";
927+
}
928+
929+
// Source URL — show domain only.
930+
if ( ! empty( $hconfig['source_url'] ) ) {
931+
$host = wp_parse_url( $hconfig['source_url'], PHP_URL_HOST );
932+
$parts[] = $host ?: $hconfig['source_url'];
933+
}
934+
935+
// Venue/source name.
936+
if ( ! empty( $hconfig['venue_name'] ) ) {
937+
$parts[] = $hconfig['venue_name'];
938+
}
939+
940+
// Feed URL — show domain only.
941+
$feed_url = $hconfig['feed_url'] ?? $hconfig['url'] ?? '';
942+
if ( $feed_url && empty( $hconfig['source_url'] ) ) {
943+
$host = wp_parse_url( $feed_url, PHP_URL_HOST );
944+
$parts[] = $host ?: $feed_url;
945+
}
946+
947+
// Taxonomy term selections (any taxonomy_*_selection key).
948+
foreach ( $hconfig as $key => $val ) {
949+
if ( strpos( $key, 'taxonomy_' ) === 0 && strpos( $key, '_selection' ) !== false ) {
950+
if ( ! empty( $val ) && 'skip' !== $val && 'ai_decides' !== $val ) {
951+
$tax_name = str_replace( array( 'taxonomy_', '_selection' ), '', $key );
952+
$parts[] = "{$tax_name}={$val}";
962953
}
963-
break;
954+
}
964955
}
965956
}
966957
}
967958

968959
$summary = implode( ' | ', array_unique( $parts ) );
969960

970-
// Truncate if too long.
971961
if ( mb_strlen( $summary ) > 60 ) {
972962
$summary = mb_substr( $summary, 0, 57 ) . '...';
973963
}

inc/Cli/Commands/PipelinesCommand.php

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -367,18 +367,17 @@ private function outputSinglePipeline( array $result, string $format ): void {
367367
}
368368

369369
/**
370-
* Extract location context from a pipeline's flows.
370+
* Extract a config summary from a pipeline's flows.
371371
*
372-
* Scans flow configs for TM coordinates, Dice city, or location taxonomy
373-
* term to provide at-a-glance location context in list output.
372+
* Scans flow handler configs for distinguishing values — coordinates,
373+
* city names, URLs, taxonomy term IDs. Domain-agnostic: reads raw
374+
* config keys without assuming any specific taxonomy or handler.
374375
*
375376
* @param array $flows Pipeline's flows array.
376-
* @return string Location summary (e.g. "32.77,-79.93" or "Charleston" or "—").
377+
* @return string Config summary or "—".
377378
*/
378379
private function extractPipelineLocation( array $flows ): string {
379-
$coords = '';
380-
$dice_city = '';
381-
$location = '';
380+
$parts = array();
382381

383382
foreach ( $flows as $flow ) {
384383
$config = $flow['flow_config'] ?? array();
@@ -389,49 +388,36 @@ private function extractPipelineLocation( array $flows ): string {
389388
foreach ( $config as $step ) {
390389
$handler_configs = $step['handler_configs'] ?? array();
391390

392-
foreach ( $handler_configs as $handler_slug => $hconfig ) {
393-
// TM coordinates.
394-
if ( ! empty( $hconfig['location'] ) && strpos( $hconfig['location'], ',' ) !== false && empty( $coords ) ) {
395-
$coords = $hconfig['location'];
391+
foreach ( $handler_configs as $hconfig ) {
392+
// Coordinates (any handler that has a location field with lat,lon).
393+
if ( ! empty( $hconfig['location'] ) && strpos( $hconfig['location'], ',' ) !== false ) {
394+
$parts[] = $hconfig['location'];
396395
}
397396

398-
// Dice city.
399-
if ( 'dice_fm' === $handler_slug && ! empty( $hconfig['city'] ) && empty( $dice_city ) ) {
400-
$dice_city = $hconfig['city'];
397+
// City name (any handler that has a city field).
398+
if ( ! empty( $hconfig['city'] ) ) {
399+
$parts[] = $hconfig['city'];
401400
}
402401

403-
// Location taxonomy term.
404-
if ( ! empty( $hconfig['taxonomy_location_selection'] ) && empty( $location ) ) {
405-
$term_val = $hconfig['taxonomy_location_selection'];
406-
if ( is_numeric( $term_val ) ) {
407-
$term = get_term( (int) $term_val, 'location' );
408-
if ( $term && ! is_wp_error( $term ) ) {
409-
$parent = $term->parent ? get_term( $term->parent, 'location' ) : null;
410-
$location = $term->name;
411-
if ( $parent && ! is_wp_error( $parent ) ) {
412-
$location .= ', ' . $parent->name;
413-
}
402+
// Taxonomy term selections (any taxonomy_*_selection config).
403+
foreach ( $hconfig as $key => $val ) {
404+
if ( strpos( $key, 'taxonomy_' ) === 0 && strpos( $key, '_selection' ) !== false ) {
405+
if ( ! empty( $val ) && 'skip' !== $val && 'ai_decides' !== $val ) {
406+
$parts[] = $val;
414407
}
415-
} else {
416-
$location = $term_val;
417408
}
418409
}
419410
}
420411
}
421-
}
422412

423-
// Return most useful identifier.
424-
if ( $location ) {
425-
return $location;
426-
}
427-
if ( $dice_city ) {
428-
return $dice_city;
429-
}
430-
if ( $coords ) {
431-
return $coords;
413+
// Stop after first flow with useful config.
414+
if ( ! empty( $parts ) ) {
415+
break;
416+
}
432417
}
433418

434-
return '';
419+
$summary = implode( ' | ', array_unique( $parts ) );
420+
return $summary ?: '';
435421
}
436422

437423
/**

0 commit comments

Comments
 (0)