From 6169b53a31cde9004ed7a157560d0ce3a650e449 Mon Sep 17 00:00:00 2001 From: Michael Bianco Date: Sat, 22 Apr 2023 06:53:25 -0600 Subject: [PATCH 1/2] adding find_bucket to magic vars example --- src/examples/querying-data.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/examples/querying-data.rst b/src/examples/querying-data.rst index 1ec8cd1..1238a47 100644 --- a/src/examples/querying-data.rst +++ b/src/examples/querying-data.rst @@ -25,20 +25,19 @@ In a query you start by getting events from a bucket and assign that collection After that you assign what you want to receive from the request to the RETURN variable. Magic Variables: - There is a magic variable `__CATEGORIES__` you can use in the web UI's Query Explorer to include your configured categories in your query. - Here's an example of using this variable to find all events categorized as "Work" + Here's an example of using this variable to find all events categorized as "Web Browsing" .. code-block:: python - events = flood(query_bucket("aw-watcher-window_")); - not_afk = flood(query_bucket("aw-watcher-afk_")); + 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 = events; + events = filter_keyvals(events, "$category", [["Web Browsing"]]); + RETURN = sort_by_duration(events); Minimal example: Minimal query which only gets events from a bucket and returns it: From 435812142ac25948160d219f80885f3837c2de4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Sun, 15 Oct 2023 12:51:27 +0200 Subject: [PATCH 2/2] Apply suggestions from code review --- src/examples/querying-data.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/examples/querying-data.rst b/src/examples/querying-data.rst index 1238a47..b55d8ce 100644 --- a/src/examples/querying-data.rst +++ b/src/examples/querying-data.rst @@ -36,7 +36,7 @@ Magic Variables: 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", [["Web Browsing"]]); + events = filter_keyvals(events, "$category", [["Work"]]); RETURN = sort_by_duration(events); Minimal example: