Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion inc/Cli/Commands/Flows/FlowsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class FlowsCommand extends BaseCommand {
*
* @var array
*/
private array $default_fields = array( 'id', 'name', 'pipeline_id', 'handlers', 'prompt', 'status', 'next_run' );
private array $default_fields = array( 'id', 'name', 'pipeline_id', 'handlers', 'schedule', 'max_items', 'prompt', 'status', 'next_run' );

/**
* Get flows with optional filtering.
Expand Down Expand Up @@ -332,6 +332,8 @@ function ( $flow ) {
'name' => $flow['flow_name'],
'pipeline_id' => $flow['pipeline_id'],
'handlers' => $this->extractHandlers( $flow ),
'schedule' => $this->extractSchedule( $flow ),
'max_items' => $this->extractMaxItems( $flow ),
'prompt' => $this->extractPrompt( $flow ),
'status' => $flow['last_run_status'] ?? 'Never',
'next_run' => $flow['next_run_display'] ?? 'Not scheduled',
Expand Down Expand Up @@ -846,6 +848,57 @@ private function extractPrompt( array $flow ): string {
return '';
}

/**
* Extract scheduling summary from flow scheduling config.
*
* @param array $flow Flow data.
* @return string Scheduling summary for list view.
*/
private function extractSchedule( array $flow ): string {
$scheduling_config = $flow['scheduling_config'] ?? array();
$interval = $scheduling_config['interval'] ?? 'manual';

if ( 'cron' === $interval && ! empty( $scheduling_config['cron_expression'] ) ) {
return 'cron:' . $scheduling_config['cron_expression'];
}

return (string) $interval;
}

/**
* Extract max_items values from handler configs in a flow.
*
* @param array $flow Flow data.
* @return string Comma-separated handler=max_items pairs, or empty string.
*/
private function extractMaxItems( array $flow ): string {
$flow_config = $flow['flow_config'] ?? array();
$pairs = array();

foreach ( $flow_config as $step_data ) {
if ( ! is_array( $step_data ) ) {
continue;
}

$handler_configs = $step_data['handler_configs'] ?? array();
if ( ! is_array( $handler_configs ) ) {
continue;
}

foreach ( $handler_configs as $handler_slug => $handler_config ) {
if ( ! is_array( $handler_config ) || ! array_key_exists( 'max_items', $handler_config ) ) {
continue;
}

$pairs[] = $handler_slug . '=' . (string) $handler_config['max_items'];
}
}

$pairs = array_values( array_unique( $pairs ) );

return implode( ', ', $pairs );
}

/**
* Add a handler to a flow step.
*
Expand Down
Loading