diff --git a/CHANGELOG.md b/CHANGELOG.md index 31e5224de5ec0c0b063093a1cbb86c008ea08f4f..c96543b2e762aae5d03eb5ed0317cb71aa78f833 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) diff --git a/app/Services/StoryService.php b/app/Services/StoryService.php index f44828899a1ce7f0b131439f1675a6fc7cc9d50e..dd53213c10913f87c91e861f65075283aa98d959 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' ]; }); }