Skip to content

Commit f98b5db

Browse files
committed
Add @node.categories as the list of category names on the current node
1 parent dbccd7f commit f98b5db

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

flows/runs/run.go

+10
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ func (r *run) Context(env envs.Environment) map[string]types.XValue {
285285
// returns the context representation of the current node
286286
//
287287
// uuid:text -> the UUID of the node
288+
// categories:array -> the category names of the node
288289
// visit_count:number -> the count of visits to the node in this run
289290
//
290291
// @context node
@@ -297,8 +298,17 @@ func (r *run) nodeContext(env envs.Environment) map[string]types.XValue {
297298
}
298299
}
299300

301+
var categories []types.XValue
302+
if node.Router() != nil {
303+
categories = make([]types.XValue, len(node.Router().Categories()))
304+
for i, c := range node.Router().Categories() {
305+
categories[i] = types.NewXText(c.Name())
306+
}
307+
}
308+
300309
return map[string]types.XValue{
301310
"uuid": types.NewXText(string(node.UUID())),
311+
"categories": types.NewXArray(categories...),
302312
"visit_count": types.NewXNumberFromInt(visitCount),
303313
}
304314
}

0 commit comments

Comments
 (0)