Skip to content

Commit

Permalink
Hotfix: parse timestamps to microseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvanleeuwen committed Mar 13, 2024
1 parent 7b791a4 commit d5e3fa6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions server/lib/mave_metrics/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,13 @@ defmodule MaveMetrics.API do
%{"from" => from_timestamp, "to" => to_timestamp},
date_field
) do
from = DateTime.from_unix!(from_timestamp) |> Timex.to_date()
to = DateTime.from_unix!(to_timestamp) |> Timex.to_date()
from =
DateTime.from_unix!(from_timestamp, :second)
|> DateTime.truncate(:microsecond)

to =
DateTime.from_unix!(to_timestamp, :second)
|> DateTime.truncate(:microsecond)

query
|> where([d], field(d, ^date_field) >= ^from and field(d, ^date_field) <= ^to)
Expand Down

0 comments on commit d5e3fa6

Please sign in to comment.