Skip to content

Commit

Permalink
docs: add __CATEGORIES__ documentation (#98)
Browse files Browse the repository at this point in the history
Co-authored-by: Erik Bjäreholt <erik.bjareholt@gmail.com>
  • Loading branch information
iloveitaly and ErikBjare committed Oct 18, 2022
1 parent bcbb4b7 commit 1ae5053
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/examples/querying-data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ For an incomplete API reference of the transform functions, see the API referenc
In a query you start by getting events from a bucket and assign that collection of events to a variable, then there are multiple transform functions which you can use to for example filter, limit, sort, and merge events from a bucket.
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"

.. code-block:: python
events = flood(query_bucket("aw-watcher-window_"));
not_afk = flood(query_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;
Minimal example:
Minimal query which only gets events from a bucket and returns it:

Expand Down

0 comments on commit 1ae5053

Please sign in to comment.