Skip to content
Snippets Groups Projects
Commit ef643009 authored by Cam Saul's avatar Cam Saul
Browse files

field-distinct-count accepts optional limit

parent c02cd9c6
No related branches found
No related tags found
No related merge requests found
......@@ -32,9 +32,12 @@
(defn field-distinct-count
"Return the distinct count of FIELD via the query processor."
[field]
{:arglists '([field] [field limit])}
[field & [limit]]
{:pre [(delay? (:table field))
(integer? (:id field))]
:post [(integer? %)]}
(-> (qp-query @(:table field) {:aggregation ["distinct" (:id field)]})
(-> (qp-query @(:table field) (merge {:aggregation ["distinct" (:id field)]}
(when limit
{:limit limit})))
first first))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment