This documentation:
https://docs.activitywatch.net/en/latest/examples/querying-data.html
Shows this example to query for only events of a certain category:
events = flood(query_bucket(find_bucket(“aw-watcher-window_”)));
not_afk = flood(query_bucket(find_bucket(“aw-watcher-afk_”)));
not_afk = filter_keyvals(not_afk, “status”, [“not-afk”]);
events = filter_period_intersect(events, not_afk);
events = categorize(events, __CATEGORIES__);
events = filter_keyvals(events, “$category”, [[“Work”]]);
RETURN = sort_by_duration(events);
Incidentally this example doesn’t work for any events that are inside a subcategory, like “[ “Work”, “Programming”, “ActivityWatch” ]”, but that’s beside the point.
I can’t seem to be able to do this with a Python based query, as the __CATEGORIES__ magic variable seems to only work from the online query builder.
I get the following error:
Error message received: {‘type’: ‘QueryInterpretException’, ‘message’: “Tried to reference variable ‘__CATEGORIES__’ which is not defined”}
Is there any way that I can do this purely from Python?