@@ -104,6 +104,8 @@ pub struct DesktopQueryParams {
104
104
pub base : QueryParamsBase ,
105
105
pub bid_window : String ,
106
106
pub bid_afk : String ,
107
+ #[ serde( default ) ]
108
+ pub always_active_pattern : Option < String > ,
107
109
}
108
110
109
111
/// Query parameters specific to Android
@@ -180,11 +182,26 @@ pub fn build_desktop_canonical_events(params: &DesktopQueryParams) -> String {
180
182
181
183
// Fetch not-afk events
182
184
if params. base . filter_afk {
183
- query . push ( format ! (
185
+ let mut not_afk_query = format ! (
184
186
"not_afk = flood(query_bucket(find_bucket(\" {}\" )));
185
187
not_afk = filter_keyvals(not_afk, \" status\" , [\" not-afk\" ])" ,
186
188
escape_doublequote( & params. bid_afk)
187
- ) ) ;
189
+ ) ;
190
+
191
+ // Add treat_as_active functionality if pattern is provided
192
+ if let Some ( ref pattern) = params. always_active_pattern {
193
+ not_afk_query. push_str ( & format ! (
194
+ ";
195
+ not_treat_as_afk = filter_keyvals_regex(events, \" app\" , \" {}\" );
196
+ not_afk = period_union(not_afk, not_treat_as_afk);
197
+ not_treat_as_afk = filter_keyvals_regex(events, \" title\" , \" {}\" );
198
+ not_afk = period_union(not_afk, not_treat_as_afk)" ,
199
+ escape_doublequote( pattern) ,
200
+ escape_doublequote( pattern)
201
+ ) ) ;
202
+ }
203
+
204
+ query. push ( not_afk_query) ;
188
205
}
189
206
190
207
// Add browser events if any browser buckets specified
@@ -362,6 +379,7 @@ mod tests {
362
379
} ,
363
380
bid_window : "aw-watcher-window_" . to_string ( ) ,
364
381
bid_afk : "aw-watcher-afk_" . to_string ( ) ,
382
+ always_active_pattern : None ,
365
383
} ;
366
384
367
385
let query = full_desktop_query ( & params) ;
@@ -414,6 +432,7 @@ mod tests {
414
432
} ,
415
433
bid_window : "test-window" . to_string ( ) ,
416
434
bid_afk : "test-afk" . to_string ( ) ,
435
+ always_active_pattern : None ,
417
436
} ;
418
437
419
438
let query_params = QueryParams :: Desktop ( params) ;
@@ -445,6 +464,7 @@ mod tests {
445
464
} ,
446
465
bid_window : "test-window" . to_string ( ) ,
447
466
bid_afk : "test-afk" . to_string ( ) ,
467
+ always_active_pattern : None ,
448
468
} ;
449
469
450
470
let query_params = QueryParams :: Desktop ( params) ;
0 commit comments