From e2e6d4c1c37aff2e6b50331cb31af9d59536624f Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Fri, 8 Nov 2019 01:21:45 +0100 Subject: [PATCH] issue: count number of replies in overview --- issue/index.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/issue/index.php b/issue/index.php index e7c69bb..f950861 100644 --- a/issue/index.php +++ b/issue/index.php @@ -51,7 +51,9 @@ if ($_POST) { $_POST = []; } -$sql = 'SELECT * FROM issues WHERE page = ?'; +$cols = "*, (SELECT count(*) FROM comments WHERE" + . " page=i.page||'/'||i.id AND message IS NOT NULL) AS replycount"; +$sql = "SELECT $cols FROM issues i WHERE page = ?"; if (isset($_GET['open'])) { $sql .= ' AND closed IS NULL'; } @@ -66,7 +68,10 @@ while ($row = $query->fetch()) { sprintf($row->closed ? '%s' : '%s', htmlspecialchars($row->subject)), showdate(array_slice(preg_split('/\D/', $row->updated), 0, 3)), - isset($row->assign) ? ' '.$row->assign.'' : '' + implode(' ', [ + $row->replycount ? sprintf('+%d', $row->replycount) : '', + isset($row->assign) ? ' '.$row->assign.'' : '', + ]) ); print "\n"; } -- 2.30.0