From 968d280304bc27c78b120cb7708e66f03b258519 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Mon, 5 Apr 2021 15:24:42 +0300 Subject: [PATCH] Fix crash when calculating visit duration with 0 sessions --- lib/plausible/stats/fragments.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plausible/stats/fragments.ex b/lib/plausible/stats/fragments.ex index 0c27f65e4..692233f10 100644 --- a/lib/plausible/stats/fragments.ex +++ b/lib/plausible/stats/fragments.ex @@ -25,7 +25,7 @@ defmodule Plausible.Stats.Fragments do defmacro visit_duration() do quote do - fragment("toUInt32(round(avg(duration * sign)))") + fragment("toUInt32(ifNotFinite(round(avg(duration * sign)), 0))") end end