Skip to content

Commit

Permalink
format: formatted with black
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Sep 29, 2024
1 parent 292b235 commit 38acb84
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
1 change: 1 addition & 0 deletions aw_client/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Taken from default classes in aw-webui
"""

import logging
import random
from typing import (
Expand Down
39 changes: 22 additions & 17 deletions aw_client/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Most of these are from: https://github.com/ActivityWatch/aw-webui/blob/master/src/queries.ts
"""

import dataclasses
import json
import re
Expand Down Expand Up @@ -104,23 +105,23 @@ def canonicalEvents(params: Union[DesktopQueryParams, AndroidQueryParams]) -> st
# Fetch window/app events
f'events = flood(query_bucket(find_bucket("{bid_window}")));',
# On Android, merge events to avoid overload of events
'events = merge_events_by_keys(events, ["app"]);'
if isAndroidParams(params)
else "",
(
'events = merge_events_by_keys(events, ["app"]);'
if isAndroidParams(params)
else ""
),
# Fetch not-afk events
f"""
(
f"""
not_afk = flood(query_bucket(find_bucket("{params.bid_afk}")));
not_afk = filter_keyvals(not_afk, "status", ["not-afk"]);
"""
if isDesktopParams(params)
else "",
if isDesktopParams(params)
else ""
),
# Fetch browser events
(
(
browserEvents(params)
if isDesktopParams(params)
else ""
)
(browserEvents(params) if isDesktopParams(params) else "")
+ ( # Include focused and audible browser events as indications of not-afk
"""
audible_events = filter_keyvals(browser_events, "audible", [true]);
Expand All @@ -133,15 +134,19 @@ def canonicalEvents(params: Union[DesktopQueryParams, AndroidQueryParams]) -> st
else ""
),
# Filter out window events when the user was afk
"events = filter_period_intersect(events, not_afk);"
if isDesktopParams(params) and params.filter_afk
else "",
(
"events = filter_period_intersect(events, not_afk);"
if isDesktopParams(params) and params.filter_afk
else ""
),
# Categorize
f"events = categorize(events, {classes_str});" if params.classes else "",
# Filter out selected categories
f'events = filter_keyvals(events, "$category", {cat_filter_str});'
if params.filter_classes
else "",
(
f'events = filter_keyvals(events, "$category", {cat_filter_str});'
if params.filter_classes
else ""
),
]
)

Expand Down
1 change: 1 addition & 0 deletions examples/load_dataframe.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Load ActivityWatch data into a dataframe, and export as CSV.
"""

import os
import socket
from datetime import datetime, timedelta, timezone
Expand Down
1 change: 1 addition & 0 deletions examples/working_hours.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from aw_transform import flood
from tabulate import tabulate


OUTPUT_HTML = os.environ.get("OUTPUT_HTML", "").lower() == "true"

td1d = timedelta(days=1)
Expand Down

0 comments on commit 38acb84

Please sign in to comment.