Skip to content

Commit b7a9fb0

Browse files
committed
fixed bug in top endpoints
1 parent b1a9d90 commit b7a9fb0

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

src/source/routes/analytics/creator/top.clj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
[{:keys [ds user query-params] :as _request}]
2323
(let [{:keys [n mindate maxdate top contenttype]} (w/keywordize-keys query-params)
24-
top-field (if (= top "post") :post-id :bundle-id)]
25-
(res/response (set/rename-keys
26-
(analytics/top-statistics-query ds mindate maxdate n top-field {:creator-id (:id user)
27-
:content-type-id contenttype})
28-
{top-field :top}))))
24+
top-field (if (= top "post") :post-id :bundle-id)
25+
results (analytics/top-statistics-query ds mindate maxdate n top-field {:creator-id (:id user)
26+
:content-type-id contenttype})]
27+
(res/response (mapv (fn [result]
28+
(set/rename-keys result {top-field :top})) results))))

src/source/routes/analytics/distributor/top.clj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
[{:keys [ds user query-params] :as _request}]
2323
(let [{:keys [n mindate maxdate top contenttype]} (w/keywordize-keys query-params)
24-
top-field (if (= top "post") :post-id :feed-id)]
25-
(res/response (set/rename-keys
26-
(analytics/top-statistics-query ds mindate maxdate n top-field {:distributor-id (:id user)
27-
:content-type-id contenttype})
28-
{top-field :top}))))
24+
top-field (if (= top "post") :post-id :feed-id)
25+
results (analytics/top-statistics-query ds mindate maxdate n top-field {:distributor-id (:id user)
26+
:content-type-id contenttype})]
27+
(res/response (mapv (fn [result]
28+
(set/rename-keys result {top-field :top})) results))))

src/source/routes/reitit.clj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,10 @@
233233
["/bundle" {:middleware [[mw/apply-bundle]]}
234234
["/posts"
235235
["/:id"
236-
["/views" (route {:post analytics-bundle-posts-id-views/post})]]]]
237-
["admin" {:middleware [[mw/apply-auth {:required-type :admin}]]}]]
236+
["/views" (route {:post analytics-bundle-posts-id-views/post})]]]]
237+
["admin" {:middleware [[mw/apply-auth {:required-type :admin}]]}
238+
["/general"]
239+
["/top"]]]
238240

239241
["/bundle" {:middleware [[mw/apply-bundle]]
240242
:tags #{"bundles"}}

0 commit comments

Comments
 (0)