Skip to content

Commit

Permalink
Use year filter first to avoid errors in old data
Browse files Browse the repository at this point in the history
  • Loading branch information
vloothuis committed Feb 6, 2024
1 parent bdf5794 commit 20caa6d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/framework/processing/py/port/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ def parse_json_to_dataframe(parsed_dict):
continue

segment = obj["activitySegment"]
activity_type = segment["activityType"]

if activity_type not in {"WALKING", "CYCLING", "RUNNING"}:
continue

start_timestamp_str = segment["duration"]["startTimestamp"]
start_timestamp = datetime.fromisoformat(
start_timestamp_str[:-1]
Expand All @@ -43,6 +38,11 @@ def parse_json_to_dataframe(parsed_dict):
if start_timestamp < filter_start_date:
continue

activity_type = segment["activityType"]

if activity_type not in {"WALKING", "CYCLING", "RUNNING"}:
continue

if meters := get_in(segment, "waypointPath", "distanceMeters"):
distance_meters = meters
elif meters := get_in(segment, "simplifiedRawPath", "distanceMeters"):
Expand Down Expand Up @@ -74,6 +74,8 @@ def aggregate_distance_by_day_activity(df):


def extract(df):
if df.empty:
return []
aggregated_df = aggregate_distance_by_day_activity(df)
aggregated_df["Afstand in m"] = aggregated_df["distanceMeters"].apply(np.ceil)

Expand Down

0 comments on commit 20caa6d

Please sign in to comment.