Skip to content

Commit 06d2069

Browse files
0xbrayoErikBjare
andauthored
feat: always-active-pattern in canonical queries (#93)
* feat: always-active-pattern in canonical queries feat:escape quotes in always-active-pattern * Apply suggestion from @ErikBjare --------- Co-authored-by: Erik Bjäreholt <erik.bjareholt@gmail.com>
1 parent f0603e3 commit 06d2069

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

aw_client/queries.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class QueryParams(_QueryParamsDefaultsBase):
5656
class _DesktopQueryParamsBase:
5757
bid_window: str
5858
bid_afk: str
59+
always_active_pattern: Optional[str] = None
5960

6061

6162
@dataclass
@@ -114,8 +115,20 @@ def canonicalEvents(params: Union[DesktopQueryParams, AndroidQueryParams]) -> st
114115
(
115116
f"""
116117
not_afk = flood(query_bucket(find_bucket("{params.bid_afk}")));
117-
not_afk = filter_keyvals(not_afk, "status", ["not-afk"]);
118-
"""
118+
not_afk = filter_keyvals(not_afk, "status", ["not-afk"]);"""
119+
+ (
120+
"""
121+
not_treat_as_afk = filter_keyvals_regex(events, "app", "%s");
122+
not_afk = period_union(not_afk, not_treat_as_afk);
123+
not_treat_as_afk = filter_keyvals_regex(events, "title", "%s");
124+
not_afk = period_union(not_afk, not_treat_as_afk);"""
125+
% (
126+
params.always_active_pattern.replace('"', '\\"'),
127+
params.always_active_pattern.replace('"', '\\"'),
128+
)
129+
if params.always_active_pattern
130+
else ""
131+
)
119132
if isDesktopParams(params)
120133
else ""
121134
),

0 commit comments

Comments
 (0)