Skip to content
Snippets Groups Projects
Commit 830e299d authored by Cam Saül's avatar Cam Saül
Browse files

tweaks

parent f2123408
Branches
Tags
No related merge requests found
......@@ -142,11 +142,10 @@
lim 10))
(defn x2 []
(Q run against geographical-tips
using mongo
aggregate rows
of tips
filter = venue...name "Kyle's Low-Carb Grill"
(Q run against geographical-tips using mongo
aggregate rows of tips
filter = source...service "yelp"
order venue...name+
limit 10))
(defn y []
......
......@@ -88,7 +88,7 @@
(defn- field->name
"Return qualified string name of FIELD, e.g. `venue` or `venue.address`."
^String [field]
(apply str (interpose "." (expand/qualified-name-components field))))
(apply str (interpose "." (rest (expand/qualified-name-components field))))) ; drop the first part, :table-name
(defn- field->$str
"Given a FIELD, return a `$`-qualified field name for use in a Mongo aggregate query, e.g. `\"$user_id\"`."
......
......@@ -175,9 +175,10 @@
(defn- limit
"Add an implicit `limit` clause to queries with `rows` aggregations, and limit the maximum number of rows that can be returned in post-processing."
[qp]
(fn [{{{ag-type :aggregation-type} :aggregation} :query, :as query}]
(fn [{{{ag-type :aggregation-type} :aggregation, limit :limit} :query, :as query}]
(let [query (cond-> query
(= ag-type :rows) (update-in [:query] #(m/assoc-some % :limit max-result-bare-rows)))
(and (not limit)
(= ag-type :rows)) (assoc-in [:query :limit] max-result-bare-rows))
results (qp query)]
(update-in results [:rows] (partial take max-result-rows)))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment