From 6ae1ba0a647787420edc156d842de61d4e7114f0 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 4 Sep 2021 17:55:58 -0600 Subject: [PATCH 1/2] Update StoryService, fix division by zero bug --- app/Services/StoryService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Services/StoryService.php b/app/Services/StoryService.php index f44828899..dd53213c1 100644 --- a/app/Services/StoryService.php +++ b/app/Services/StoryService.php @@ -121,9 +121,9 @@ class StoryService 'sum' => (int) Story::sum('size'), 'average' => (int) Story::avg('size') ], - 'avg_spu' => (int) ($total / Story::groupBy('profile_id')->pluck('profile_id')->count()), + 'avg_spu' => $total ? (int) ($total / Story::groupBy('profile_id')->pluck('profile_id')->count()) : 'N/A', 'avg_duration' => (int) floor(Story::avg('duration')), - 'avg_type' => Story::selectRaw('type, count(id) as count')->groupBy('type')->orderByDesc('count')->first()->type + 'avg_type' => $total ? Story::selectRaw('type, count(id) as count')->groupBy('type')->orderByDesc('count')->first()->type : 'N/A' ]; }); } From c3ffd5cbd63b1cdf0fa550264e70ab7841b608f2 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 4 Sep 2021 18:05:43 -0600 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31e5224de..c96543b2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,6 +107,7 @@ - Updated StoryComposeController, fix expiry bug. ([7dee8f58](https://github.com/pixelfed/pixelfed/commit/7dee8f58)) - Updated Profile, fix following count bug. ([ee9f0795](https://github.com/pixelfed/pixelfed/commit/ee9f0795)) - Updated DirectMessageController, fix autocomplete bug. ([0f00be4d](https://github.com/pixelfed/pixelfed/commit/0f00be4d)) +- Updated StoryService, fix division by zero bug. ([6ae1ba0a](https://github.com/pixelfed/pixelfed/commit/6ae1ba0a)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.0 (2021-06-01)](https://github.com/pixelfed/pixelfed/compare/v0.10.10...v0.11.0)