diff options
Diffstat (limited to 'events/src/handlers.py')
-rw-r--r-- | events/src/handlers.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/events/src/handlers.py b/events/src/handlers.py index 9b756a91d51..21d3e83de54 100644 --- a/events/src/handlers.py +++ b/events/src/handlers.py @@ -19,3 +19,22 @@ def generic_handler(ts, key, data): Ex: handle_event_volume_create(ts, key, data) """ utils.publish(ts, key, data) + + +def handle_event_volume_set(ts, key, data): + """ + Recieved data will have all the options as one string, split into + list of options. "key1,value1,key2,value2" into + [[key1, value1], [key2, value2]] + """ + opts = data.get("options", "").strip(",").split(",") + data["options"] = [] + for i, opt in enumerate(opts): + if i % 2 == 0: + # Add new array with key + data["options"].append([opt]) + else: + # Add to the last added array + data["options"][-1].append(opt) + + utils.publish(ts, key, data) |