Skip to content

Commit

Permalink
Add execution time (time_exec) table column for activity lists
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Dec 8, 2023
1 parent 9610e48 commit 93fc82e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 19 deletions.
33 changes: 23 additions & 10 deletions src/Command/Activity/ActivityListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@

class ActivityListCommand extends ActivityCommandBase
{
private $tableHeader = ['ID', 'Created', 'Completed', 'Description', 'Type', 'Progress', 'State', 'Result', 'environments' => 'Environment(s)'];
private $tableHeader = [
'id' => 'ID',
'created' => 'Created',
'completed' => 'Completed',
'description' => 'Description',
'type' => 'Type',
'progress' => 'Progress',
'state' => 'State',
'result' => 'Result',
'environments' => 'Environment(s)',
'time_exec' => 'Execution time (s)',
];
private $defaultColumns = ['id', 'created', 'description', 'progress', 'state', 'result'];

/**
Expand Down Expand Up @@ -97,16 +108,18 @@ protected function execute(InputInterface $input, OutputInterface $output)

$rows = [];
foreach ($activities as $activity) {
$timings = $activity->getProperty('timings', false, false) ?: [];
$rows[] = [
new AdaptiveTableCell($activity->id, ['wrap' => false]),
$formatter->format($activity['created_at'], 'created_at'),
$formatter->format($activity['completed_at'], 'completed_at'),
ActivityMonitor::getFormattedDescription($activity, !$table->formatIsMachineReadable()),
new AdaptiveTableCell($activity->type, ['wrap' => false]),
$activity->getCompletionPercent() . '%',
ActivityMonitor::formatState($activity->state),
ActivityMonitor::formatResult($activity->result, !$table->formatIsMachineReadable()),
implode(', ', $activity->environments)
'id' => new AdaptiveTableCell($activity->id, ['wrap' => false]),
'created' => $formatter->format($activity['created_at'], 'created_at'),
'completed' => $formatter->format($activity['completed_at'], 'completed_at'),
'description' => ActivityMonitor::getFormattedDescription($activity, !$table->formatIsMachineReadable()),
'type' => new AdaptiveTableCell($activity->type, ['wrap' => false]),
'progress' => $activity->getCompletionPercent() . '%',
'state' => ActivityMonitor::formatState($activity->state),
'result' => ActivityMonitor::formatResult($activity->result, !$table->formatIsMachineReadable()),
'environments' => implode(', ', $activity->environments),
'time_exec' => isset($timings['execute']) ? (string) $timings['execute'] : '',
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@

class IntegrationActivityListCommand extends IntegrationCommandBase
{
private $tableHeader = ['ID', 'Created', 'Completed', 'Description', 'Type', 'State', 'Result'];
private $defaultColumns = ['ID', 'Created', 'Description', 'Type', 'State', 'Result'];
private $tableHeader = [
'id' => 'ID',
'created' => 'Created',
'completed' => 'Completed',
'description' => 'Description',
'progress' => 'Progress',
'type' => 'Type',
'state' => 'State',
'result' => 'Result',
'time_exec' => 'Execution time (s)',
];
private $defaultColumns = ['id', 'created', 'description', 'type', 'state', 'result'];

/**
* {@inheritdoc}
Expand Down Expand Up @@ -77,14 +87,17 @@ protected function execute(InputInterface $input, OutputInterface $output)

$rows = [];
foreach ($activities as $activity) {
$timings = $activity->getProperty('timings', false, false) ?: [];
$rows[] = [
new AdaptiveTableCell($activity->id, ['wrap' => false]),
$formatter->format($activity['created_at'], 'created_at'),
$formatter->format($activity['completed_at'], 'completed_at'),
ActivityMonitor::getFormattedDescription($activity, !$table->formatIsMachineReadable()),
new AdaptiveTableCell($activity->type, ['wrap' => false]),
ActivityMonitor::formatState($activity->state),
ActivityMonitor::formatResult($activity->result, !$table->formatIsMachineReadable()),
'id' => new AdaptiveTableCell($activity->id, ['wrap' => false]),
'created' => $formatter->format($activity['created_at'], 'created_at'),
'completed' => $formatter->format($activity['completed_at'], 'completed_at'),
'description' => ActivityMonitor::getFormattedDescription($activity, !$table->formatIsMachineReadable()),
'type' => new AdaptiveTableCell($activity->type, ['wrap' => false]),
'progress' => $activity->getCompletionPercent() . '%',
'state' => ActivityMonitor::formatState($activity->state),
'result' => ActivityMonitor::formatResult($activity->result, !$table->formatIsMachineReadable()),
'time_exec' => isset($timings['execute']) ? (string) $timings['execute'] : '',
];
}

Expand Down

0 comments on commit 93fc82e

Please sign in to comment.