Skip to content

Commit

Permalink
Robustly handle timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
vladsavelyev committed Jul 3, 2024
1 parent 2e0ba43 commit 97e550b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def version(
"""
background_tasks.add_task(
_log_visit,
timestamp=datetime.datetime.now().isoformat(),
timestamp=datetime.datetime.now().isoformat(timespec="microseconds"),
version_multiqc=version_multiqc,
version_python=version_python,
operating_system=operating_system,
Expand Down Expand Up @@ -240,7 +240,7 @@ def _summarize_visits(interval="5min") -> Response:
dtype="string",
na_filter=False, # prevent empty strings from converting to nan or <NA>
)
df["start"] = pd.to_datetime(df["timestamp"])
df["start"] = pd.to_datetime(df["timestamp"], format="%Y-%m-%dT%H:%M:%S.%f", errors="coerce")
df["end"] = df["start"] + pd.to_timedelta(interval)
df["start"] = df["start"].dt.strftime("%Y-%m-%d %H:%M")
df["end"] = df["end"].dt.strftime("%Y-%m-%d %H:%M")
Expand Down

0 comments on commit 97e550b

Please sign in to comment.