Skip to content

Commit

Permalink
needs to be naive...
Browse files Browse the repository at this point in the history
  • Loading branch information
swiffer committed Sep 29, 2024
1 parent b89d288 commit 8cdb3ba
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/teslamate/log.ex
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ defmodule TeslaMate.Log do
def get_positions_without_elevation(min_id \\ 0, opts \\ []) do

Check warning on line 173 in lib/teslamate/log.ex

View workflow job for this annotation

GitHub Actions / Lint (Elixir 1.16.2 / OTP 26)

no_return

Function get_positions_without_elevation/0 has no local return.

Check warning on line 173 in lib/teslamate/log.ex

View workflow job for this annotation

GitHub Actions / Lint (Elixir 1.16.2 / OTP 26)

no_return

Function get_positions_without_elevation/1 has no local return.

Check warning on line 173 in lib/teslamate/log.ex

View workflow job for this annotation

GitHub Actions / Lint (Elixir 1.16.2 / OTP 26)

no_return

Function get_positions_without_elevation/2 has no local return.
limit = Keyword.get(opts, :limit, 100)

date_earliest =
{:ok, date_earliest} =

Check warning on line 176 in lib/teslamate/log.ex

View workflow job for this annotation

GitHub Actions / Lint (Elixir 1.16.2 / OTP 26)

pattern_match

The pattern can never match the type
cond do
min_id == 0 and Mix.env() != :test ->
DateTime.add(DateTime.utc_now(), -10, :day)
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit 8cdb3ba

Please sign in to comment.