Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(defn bounces [root]
(let [ybtag (select-fields (ybtag-tap root) ["!psn" "!pvi" "!lo" "!g_C" "!g_r" "!g_c" "!r" "!b"])
b-sq (<- [!pub !pv-id !b]
(ybtag !pub !pv-id _ _ _ _ _ !b)
(not= !b nil))
rest-sq (<- [!pub !pv-id !country !region !city !kw !ref !url]
(ybtag !pub !pv-id !url !country !region !city !r _)
(not= !r nil)
(expand-fields !r :> !kw !ref))
bounces-sq (<- [!pub !country !region !city !kw !ref !url !pv-id ?c]
(b-sq !pub !pv-id !!b)
(rest-sq !pub !pv-id !country !region !city !kw !ref !url)
(= !!b "1")
(c/count ?c))]
(<- [!pub !country !region !city !kw !ref !url ?s]
(bounces-sq !pub !country !region !city !kw !ref !url !pv-id ?c)
(c/sum ?c :> ?s)
)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment