skip entries not from selected workspace

This commit is contained in:
bain 2022-08-28 01:05:23 +02:00
parent e0eea41214
commit 89be8f3589
No known key found for this signature in database
GPG key ID: A708F07AF3D92C02

View file

@ -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"),