diff --git a/things2reclaim/main.py b/things2reclaim/main.py index 6f88c1e..972cd18 100755 --- a/things2reclaim/main.py +++ b/things2reclaim/main.py @@ -179,7 +179,6 @@ def start_task( return toggl_handler.start_task(task.name, reclaim_handler.get_project(task)) - reclaim_handler.start_task(task) print(f"Started task {task.name}") diff --git a/things2reclaim/reclaim_handler.py b/things2reclaim/reclaim_handler.py index a730ce6..0bf3149 100644 --- a/things2reclaim/reclaim_handler.py +++ b/things2reclaim/reclaim_handler.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, date, timedelta from pathlib import Path from typing import List, Dict @@ -32,12 +32,14 @@ def get_project(task: ReclaimTask): return task.name.split(" ")[0] -def get_events(since_days: int = 1): - return ReclaimTaskEvent.search() +def get_events_since(since_days: int = 1): + date_now = datetime.now(tz.tzutc()).date() + date_since = date_now - timedelta(days=since_days) + return ReclaimTaskEvent.search(date_since, date_now) -def start_task(task: ReclaimTask): - task.prioritize() +def get_events_date_range(from_date: date, to_date: date): + return ReclaimTaskEvent.search(from_date, to_date) def create_reaclaim_task_from_dict(params: Dict): diff --git a/things2reclaim/toggl_handler.py b/things2reclaim/toggl_handler.py index 020bc62..5541daa 100644 --- a/things2reclaim/toggl_handler.py +++ b/things2reclaim/toggl_handler.py @@ -1,5 +1,5 @@ import difflib -from datetime import datetime, timedelta +from datetime import datetime, timedelta, date from pathlib import Path import tomllib @@ -32,7 +32,13 @@ def get_time_entry(time_entry_id: int): return toggl_python.TimeEntries(auth=auth).retrieve(time_entry_id) -def get_time_entries(since_days: int = 30): +def get_time_entries_date_range(from_date: date, to_date: date): + return toggl_python.TimeEntries(auth=auth).list( + start_date=from_date.isoformat(), end_date=to_date.isoformat() + ) + + +def get_time_entries_since(since_days: int = 30): if since_days > 90: raise ValueError("since_days can't be more than 90 days") time_stamp = int((datetime.now() - timedelta(days=since_days)).timestamp())