From d3347a1be02556f311d6537206506e7622c7e5c5 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 20 Sep 2022 21:15:57 +0200 Subject: [PATCH] :sparkles: Allow floats on db/interval constructor --- backend/src/app/db.clj | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/src/app/db.clj b/backend/src/app/db.clj index d628308e1..0da1fcf24 100644 --- a/backend/src/app/db.clj +++ b/backend/src/app/db.clj @@ -367,23 +367,23 @@ (.rollback conn sp))) (defn interval - [data] + [o] (cond - (integer? data) - (->> (/ data 1000.0) + (or (integer? o) + (float? o)) + (->> (/ o 1000.0) (format "%s seconds") (pginterval)) - (string? data) - (pginterval data) + (string? o) + (pginterval o) - (dt/duration? data) - (->> (/ (.toMillis ^java.time.Duration data) 1000.0) - (format "%s seconds") - (pginterval)) + (dt/duration? o) + (interval (inst-ms o)) :else - (ex/raise :type :not-implemented))) + (ex/raise :type :not-implemented + :hint (format "no implementation found for value %s" (pr-str o))))) (defn decode-json-pgobject [^PGobject o]