another bug fix
This commit is contained in:
parent
4e39127952
commit
00bcc828f4
1 changed files with 9 additions and 8 deletions
|
@ -98,6 +98,13 @@ def get_toggl_entries(
|
|||
)
|
||||
projects = {p["id"]: p["name"] for p in resp.json()}
|
||||
|
||||
def valid_entry(e):
|
||||
return (
|
||||
e["duration"] > 0
|
||||
and e["server_deleted_at"] is None
|
||||
and e["project_id"] in projects
|
||||
)
|
||||
|
||||
entries = []
|
||||
resp = requests.get(
|
||||
f"https://api.track.toggl.com/api/v9/me/time_entries",
|
||||
|
@ -111,9 +118,7 @@ def get_toggl_entries(
|
|||
entries = resp.json()
|
||||
last_entry = next(
|
||||
filter(
|
||||
lambda x: x["duration"] > 0
|
||||
and entry["server_deleted_at"] is None
|
||||
and entry["project_id"] in projects,
|
||||
valid_entry,
|
||||
entries,
|
||||
),
|
||||
None,
|
||||
|
@ -122,11 +127,7 @@ 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 # running entry
|
||||
or entry["server_deleted_at"] is not None # deleted entry
|
||||
or entry["project_id"] not in projects # entry not from selected workspace
|
||||
):
|
||||
if not valid_entry(entry):
|
||||
continue
|
||||
start = datetime.datetime.fromisoformat(entry["start"].replace("Z", "+00:00"))
|
||||
end = datetime.datetime.fromisoformat(entry["stop"].replace("Z", "+00:00"))
|
||||
|
|
Loading…
Reference in a new issue