Call amazing marvin less often
This commit is contained in:
@@ -32,8 +32,8 @@ def get_tracked_task(api_token: str) -> Optional[Dict[str, Any]]:
|
||||
|
||||
def setup_activitywatch_client() -> Tuple[ActivityWatchClient, str]:
|
||||
"""Initialize ActivityWatch client and create bucket."""
|
||||
client = ActivityWatchClient("amazing-marvin-watcher", testing=False)
|
||||
bucket_id = f"amazing-marvin-task_{client.client_hostname}"
|
||||
client = ActivityWatchClient("aw-watcher-marvin", testing=False)
|
||||
bucket_id = f"aw-watcher-marvin_{client.client_hostname}"
|
||||
event_type = "amazing-marvin-task"
|
||||
|
||||
try:
|
||||
@@ -45,13 +45,13 @@ def setup_activitywatch_client() -> Tuple[ActivityWatchClient, str]:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def create_task_event(tracked_task: Optional[Dict[str, Any]]) -> Optional[Event]:
|
||||
def create_task_event(tracked_task: Dict[str, Any]) -> Event:
|
||||
"""Create an ActivityWatch event from a tracked Amazing Marvin task."""
|
||||
if not tracked_task:
|
||||
return None
|
||||
|
||||
event_data = {
|
||||
"task_title": tracked_task.get("title", "Unknown Task"),
|
||||
"title": tracked_task.get("title", "Unknown Task"),
|
||||
"task_id": tracked_task.get("_id", ""),
|
||||
"database": tracked_task.get("db", "Tasks"),
|
||||
"app": "Amazing Marvin",
|
||||
@@ -79,7 +79,7 @@ def main() -> None:
|
||||
print("Press Ctrl+C to stop")
|
||||
|
||||
current_task_id = None
|
||||
heartbeat_interval = 30 # seconds
|
||||
heartbeat_interval = 60
|
||||
|
||||
try:
|
||||
with client:
|
||||
@@ -95,13 +95,12 @@ def main() -> None:
|
||||
print(f"Now tracking: {task_title}")
|
||||
|
||||
event = create_task_event(tracked_task)
|
||||
if event:
|
||||
client.heartbeat(
|
||||
bucket_id,
|
||||
event,
|
||||
pulsetime=int(heartbeat_interval * 1.5),
|
||||
queued=True,
|
||||
)
|
||||
client.heartbeat(
|
||||
bucket_id,
|
||||
event,
|
||||
pulsetime=int(heartbeat_interval * 2.1),
|
||||
queued=True,
|
||||
)
|
||||
else:
|
||||
if current_task_id is not None:
|
||||
current_task_id = None
|
||||
|
||||
Reference in New Issue
Block a user