Skip to content

Instantly share code, notes, and snippets.

@sorenmacbeth
Created August 5, 2011 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorenmacbeth/1128231 to your computer and use it in GitHub Desktop.
Save sorenmacbeth/1128231 to your computer and use it in GitHub Desktop.
(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