Skip to content

Instantly share code, notes, and snippets.

@tangrammer
Created June 19, 2018 15:03
Show Gist options
  • Save tangrammer/d34d769bbbc244652ebd9410be57ae8b to your computer and use it in GitHub Desktop.
Save tangrammer/d34d769bbbc244652ebd9410be57ae8b to your computer and use it in GitHub Desktop.
example aggregation generation data from specs
(in-ns 'akvo.lumen.specs.aggregation)
(def s* lumen.s/sample)
(s* ::l.aggregation.filter/filter)
;; => {:operation "remove",
;; :strategy "isLower",
;; :value "3hrEm8YaB0ZxnuS",
;; :column
;; {:columnName "d3",
;; :title "Iy0eFt6vRgMcX",
;; :type "number",
;; :sort nil,
;; :hidden true}}(s/def ::l.aggregation.filter/categoryColumn ::dataset.s/column)
(s* ::l.aggregation.filter/filters)
;; => [{:operation "remove",
;; :strategy "isEmpty",
;; :value nil,
;; :column {:columnName "d3", :sort -76896890}}
;; {:operation "remove",
;; :strategy "isHigher",
;; :value "0u",
;; :column
;; {:columnName "d1",
;; :direction nil,
;; :sort 247,
;; :title "o6fVYp17Mh7",
;; :hidden true}}
;; {:operation "keep",
;; :strategy "isEmpty",
;; :value "62q4sE3tOQ8xR",
;; :column
;; {:columnName "d1",
;; :sort -54,
;; :direction "uNG1RvVKm5j2In5P8",
;; :title "5e7mAx8O6p1y4QaeKVfkRTs56cir4",
;; :hidden false,
;; :type "date"}}]
(s* ::l.aggregation.pivot/query)
;; => {:aggregation "count",
;; :rowColumn nil,
;; :categoryColumn "22r8eNA28fU4ISr4341wqdG",
;; :filters
;; [{:operation "keep",
;; :strategy "is",
;; :value "j6796tvEl0KjeKE05x",
;; :column "l2lz1w8dZ51758Ae"}
;; {:operation "keep",
;; :strategy "isHigher",
;; :value "xEcKxip4k31",
;; :column "JG5i4R6JOE"}
;; {:operation "keep",
;; :strategy "is",
;; :value "SE",
;; :column "JRJ1L7i9"}]}
(s* ::l.aggregation.pivot/query-built)
;; => {:aggregation "min",
;; :row-column {:columnName "d2", :hidden false, :title "izc204B4Jm"},
;; :category-column
;; {:columnName "d2",
;; :hidden false,
;; :type "text",
;; :title "s1p",
;; :direction "17ap4yCpBrp4EZMf847yq85",
;; :sort nil},
;; :filters nil,
;; :value-column
;; {:columnName "d3",
;; :direction nil,
;; :title "66",
;; :type "date",
;; :hidden false,
;; :sort nil}}
(s* ::l.aggregation.pivot/row)
;; => {:type "6F3Vv20eSkt7R6r2ES7KQJ",
;; :title "r3N5s0Sx9jVc93tpAOiuZIHfNyCX"}
(s* ::l.aggregation.pivot/apply-query-ret)
;; => {:rows
;; [{:type "s6cm7", :title "Gj71N9EK3c1OMKV8a4U"}
;; {:type "o8Ct3blS6A1CKge", :title "7oUVMp67L"}],
;; :columns 34398364}
(s* ::l.aggregation.pie/query)
;; => {:bucketColumn "Zp0RiyPW44I",
;; :filters
;; [{:operation "keep",
;; :strategy "is",
;; :value nil,
;; :column "7EADOX2X16g42FRkSA6244UbWkH"}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment