From 8cdb3badd0dd75d7b71c5e9f09aecb36eb9ae75c Mon Sep 17 00:00:00 2001 From: Matthias Wirtz Date: Sun, 29 Sep 2024 18:47:21 +0200 Subject: [PATCH] needs to be naive... --- lib/teslamate/log.ex | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/teslamate/log.ex b/lib/teslamate/log.ex index d4f1487a8e..c4fb7cef09 100644 --- a/lib/teslamate/log.ex +++ b/lib/teslamate/log.ex @@ -173,7 +173,7 @@ defmodule TeslaMate.Log do def get_positions_without_elevation(min_id \\ 0, opts \\ []) do limit = Keyword.get(opts, :limit, 100) - date_earliest = + {:ok, date_earliest} = cond do min_id == 0 and Mix.env() != :test -> DateTime.add(DateTime.utc_now(), -10, :day) @@ -182,6 +182,8 @@ defmodule TeslaMate.Log do DateTime.from_iso8601("2003-07-01T00:00:00Z") end + naive_date_earliest = DateTime.to_naive(date_earliest) + non_streamed_drives = Repo.all( from p in Position, @@ -190,8 +192,8 @@ defmodule TeslaMate.Log do }, join: d in assoc(p, :drive), where: - p.date > ^date_earliest and - d.start_date > ^date_earliest, + p.date > ^naive_date_earliest and + d.start_date > ^naive_date_earliest, having: count() |> filter(not is_nil(p.odometer) and is_nil(p.ideal_battery_range_km)) > 0, @@ -202,7 +204,7 @@ defmodule TeslaMate.Log do |> where( [p], p.id > ^min_id and is_nil(p.elevation) and p.drive_id in ^non_streamed_drives and - p.date > ^date_earliest + p.date > ^naive_date_earliest ) |> order_by(asc: :id) |> limit(^limit)