Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aw_client/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_classes() -> List[Tuple[List[str], dict]]:
Get classes from server-side settings.
Might throw a 404 if not set yet, in which case we use the default classes as a fallback.
"""
# NOTE: Always tries to fetch from prod server,
# NOTE: tries to fetch from prod server,
# which is potentially wrong if testing server is being used.
awc = aw_client.ActivityWatchClient(f"get-setting-{random.randint(0, 10000)}")
try:
Expand Down
17 changes: 15 additions & 2 deletions aw_client/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class QueryParams(_QueryParamsDefaultsBase):
class _DesktopQueryParamsBase:
bid_window: str
bid_afk: str
always_active_pattern: Optional[str] = None


@dataclass
Expand Down Expand Up @@ -114,8 +115,20 @@ def canonicalEvents(params: Union[DesktopQueryParams, AndroidQueryParams]) -> st
(
f"""
not_afk = flood(query_bucket(find_bucket("{params.bid_afk}")));
not_afk = filter_keyvals(not_afk, "status", ["not-afk"]);
"""
not_afk = filter_keyvals(not_afk, "status", ["not-afk"]);"""
+ (
"""
not_treat_as_afk = filter_keyvals_regex(events, "app", "%s");
not_afk = period_union(not_afk, not_treat_as_afk);
not_treat_as_afk = filter_keyvals_regex(events, "title", "%s");
not_afk = period_union(not_afk, not_treat_as_afk);"""
% (
params.always_active_pattern.replace('"', '\\"'),
params.always_active_pattern.replace('"', '\\"'),
)
if params.always_active_pattern
else ""
)
if isDesktopParams(params)
else ""
),
Expand Down
Loading