Skip to content

Commit

Permalink
fix: adding find_bucket to magic vars example (#117)
Browse files Browse the repository at this point in the history
* adding find_bucket to magic vars example

* Apply suggestions from code review

---------

Co-authored-by: Erik Bjäreholt <[email protected]>
  • Loading branch information
iloveitaly and ErikBjare authored Oct 15, 2023
1 parent b52a78c commit ae58fb4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/examples/querying-data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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;
RETURN = sort_by_duration(events);
Minimal example:
Minimal query which only gets events from a bucket and returns it:
Expand Down

0 comments on commit ae58fb4

Please sign in to comment.