Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding find_bucket to magic vars example #117

Merged
merged 2 commits into from Oct 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/examples/querying-data.rst
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;
events = filter_keyvals(events, "$category", [["Web Browsing"]]);
ErikBjare marked this conversation as resolved.
Show resolved Hide resolved
RETURN = sort_by_duration(events);

Minimal example:
Minimal query which only gets events from a bucket and returns it:
Expand Down