From e5e509ea218a34f762c48713ced815bbeb7bbc99 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 24 May 2022 22:32:30 +0200 Subject: [PATCH] Calculate totals --- src/Console/MoveToAvatarCache.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Console/MoveToAvatarCache.php b/src/Console/MoveToAvatarCache.php index 3682eb35a5..91fce6cf4b 100644 --- a/src/Console/MoveToAvatarCache.php +++ b/src/Console/MoveToAvatarCache.php @@ -96,13 +96,15 @@ HELP; } $count = 0; + $totals = $this->dba->p("SELECT COUNT(DISTINCT(`resource-id`)) AS `total` FROM `photo` WHERE `contact-id` != ? AND `photo-type` = ?;", 0, Photo::CONTACT_AVATAR); + $total = $this->dba->fetch($totals)['total'] ?? 0; $photos = $this->dba->p("SELECT `resource-id`, MAX(`contact-id`) AS `contact-id` FROM `photo` WHERE `contact-id` != ? AND `photo-type` = ? GROUP BY `resource-id`;", 0, Photo::CONTACT_AVATAR); while ($photo = $this->dba->fetch($photos)) { $contact = Contact::getById($photo['contact-id'], ['id', 'avatar', 'photo', 'uri-id', 'url', 'avatar']); if (empty($contact)) { continue; } - echo ++$count . "\t" . $contact['id'] . "\t" . $contact['url'] . "\t"; + echo ++$count . '/' . $total . "\t" . $contact['id'] . "\t" . $contact['url'] . "\t"; $this->storeAvatar($photo['resource-id'], $contact, true); } return 0; -- 2.39.5