From 91d55a54d153fbae7928c11c3c0256866e0c58a2 Mon Sep 17 00:00:00 2001 From: davidvanleeuwen Date: Wed, 21 Feb 2024 15:42:35 +0100 Subject: [PATCH] fix: use date instead of datetime --- server/lib/mave_metrics/api.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/lib/mave_metrics/api.ex b/server/lib/mave_metrics/api.ex index dfef08c..43feb5d 100644 --- a/server/lib/mave_metrics/api.ex +++ b/server/lib/mave_metrics/api.ex @@ -129,15 +129,15 @@ defmodule MaveMetrics.API do end defp apply_timeframe(query, %{"from" => from_timestamp, "to" => to_timestamp}) do - {:ok, from} = DateTime.from_unix(from_timestamp) - {:ok, to} = DateTime.from_unix(to_timestamp) + from = DateTime.from_unix!(from_timestamp) |> Timex.to_date() + to = DateTime.from_unix!(to_timestamp) |> Timex.to_date() query |> where([d], d.session_date >= ^from and d.session_date <= ^to) end defp apply_timeframe(query, timeframe) when is_number(timeframe) do - {:ok, from} = DateTime.from_unix(timeframe) + from = DateTime.from_unix!(timeframe) |> Timex.to_date() query |> where([d], d.session_date >= ^from)