diff --git a/re/src/re/handler/json2orc.clj b/re/src/re/handler/json2orc.clj index 92a7edc..ecd6515 100644 --- a/re/src/re/handler/json2orc.clj +++ b/re/src/re/handler/json2orc.clj @@ -1,6 +1,7 @@ (ns re.handler.json2orc (:require [integrant.core :as ig]) - (:require [clojure.java.shell :as shell])) + (:require [clojure.java.shell :as shell] + [clojure.string :as string :refer [join] :rename {join j}])) (defn compile-orc [orc] (shell/sh @@ -8,8 +9,21 @@ :dir "/usr/oam-compiler" :in orc)) +(defn header [campaign] + (j ["{-\n" + " - campaign_id: " (:campaign_id campaign) "\n" + " - name: " (:name campaign) "\n" + " - app_id: " (:app_id campaign) "\n" + " - type: " (:type campaign) "\n" + " -}\n"])) + +(defn add-segments [campaign] + campaign) + (defn convert [json] - (let [orc "1>>2" + (let [campaign (add-segments json) + orc (j [(header campaign) + "\n1>>2"]) compile-result (compile-orc orc) result {:orc orc}] (if (= (:exit compile-result) 0)