Browse and delete polls from a numbered list in the polls menu
CI / Deploy / PHP 8.5 (push) Successful in 1m7s
CI / Deploy / PHP 8.4 (push) Successful in 1m12s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped

Paged list with pick by number (open) and "d 1,3" to delete several at
once after one confirmation. List query and table moved into the shared
base command.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-16 13:35:38 +01:00
1 parent 6e8fef022b
commit 7b83cf2f2c
6 files changed
+202 -39

No files matched your search

+2 -29
View File
@@ -51,22 +51,8 @@ class PollsListCommand extends PollsCommand
*/
public function execute(Arguments $args, ConsoleIo $io): int
{
$query = $this->polls()->find()
->select([
'Polls.id', 'Polls.title', 'Polls.email', 'Polls.join_code', 'Polls.current_slide_id',
'Polls.paused_slide_id', 'Polls.last_admin_access', 'Polls.expiry_reminded_at', 'Polls.created',
])
->orderBy(['Polls.id' => 'ASC']);
if ($args->getOption('expired')) {
$query->find('expired');
}
$email = $args->getOption('email');
if (is_string($email) && $email !== '') {
$query->where(['Polls.email LIKE' => '%' . addcslashes(strtolower($email), '%_\\') . '%']);
}
/** @var list<\App\Model\Entity\Poll> $polls */
$polls = $query->all()->toList();
$polls = $this->findPolls((bool)$args->getOption('expired'), is_string($email) ? $email : '');
$sort = (string)$args->getOption('sort');
if ($sort !== 'created') {
usort($polls, fn($a, $b): int => match ($sort) {
@@ -81,20 +67,7 @@ class PollsListCommand extends PollsCommand
return static::CODE_SUCCESS;
}
$rows = [[__('ID'), __('Code'), __('Titel'), __('E-Mail'), __('Angelegt'), __('Letzter Admin-Besuch'), __('Läuft ab'), __('Erinnert')]];
foreach ($polls as $poll) {
$rows[] = [
(string)$poll->id,
$poll->join_code,
mb_strimwidth($poll->title, 0, 40, '…'),
$poll->email,
$this->formatDate($poll->created),
$this->formatDate($poll->last_admin_access),
$this->formatExpiry($poll),
$this->formatDate($poll->expiry_reminded_at),
];
}
$io->helper('Table')->output($rows);
$this->printPolls($polls, $io);
$expired = count(array_filter($polls, fn($poll): bool => $poll->isExpired()));
$io->out(__('{0} Umfrage(n), davon {1} abgelaufen.', count($polls), $expired));