From 89be8f3589fded2e32f36b2c69777200fa28ce1a Mon Sep 17 00:00:00 2001 From: bain Date: Sun, 28 Aug 2022 01:05:23 +0200 Subject: [PATCH] skip entries not from selected workspace --- toggl2sheets.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/toggl2sheets.py b/toggl2sheets.py index 18aee2b..4219428 100644 --- a/toggl2sheets.py +++ b/toggl2sheets.py @@ -114,12 +114,17 @@ def get_toggl_entries( # construct a dict of d["project name"] = [[date, description, duration (hours), wage], ...] out = defaultdict(list) for entry in reversed(entries): - if entry["duration"] <= 0 or entry["server_deleted_at"] is not None: - continue # running entries and deleted entries + if ( + entry["duration"] <= 0 # running entry + or entry["server_deleted_at"] is not None # deleted entry + or entry["project_id"] not in projects # entry not from selected workspace + ): + continue start = datetime.datetime.fromisoformat(entry["start"].replace("Z", "+00:00")) end = datetime.datetime.fromisoformat(entry["stop"].replace("Z", "+00:00")) if end <= last_edit: continue # get better accuracy than toggl lets us in their requests + out[projects[entry["project_id"]]].append( [ start.astimezone().strftime("%-d. %-m. %Y"),