fix view-snippets sorting
This commit is contained in:
parent
a90cabf605
commit
9146f2640d
2 changed files with 15 additions and 9 deletions
|
|
@ -5,16 +5,20 @@ meta {
|
||||||
}
|
}
|
||||||
|
|
||||||
get {
|
get {
|
||||||
url: {{host}}/api/snippets?limit=2&skip=0
|
url: {{host}}/api/snippets?limit=100&skip=0
|
||||||
body: none
|
body: none
|
||||||
auth: none
|
auth: none
|
||||||
}
|
}
|
||||||
|
|
||||||
params:query {
|
params:query {
|
||||||
limit: 2
|
limit: 100
|
||||||
skip: 0
|
skip: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
headers {
|
||||||
|
~Accept: application/edn
|
||||||
|
}
|
||||||
|
|
||||||
body:json {
|
body:json {
|
||||||
{
|
{
|
||||||
"title": "Test Snippet",
|
"title": "Test Snippet",
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,15 @@
|
||||||
(assoc snippet :pub-date (.toString (:pub-date snippet)))))
|
(assoc snippet :pub-date (.toString (:pub-date snippet)))))
|
||||||
|
|
||||||
(defn view-snippets [options]
|
(defn view-snippets [options]
|
||||||
(if (nil? options)
|
|
||||||
(map serialize-snippet (db/list-snippets))
|
|
||||||
(let [limit (:limit options)
|
(let [limit (:limit options)
|
||||||
skip (:skip options)]
|
skip (:skip options)
|
||||||
(->> (db/list-snippets)
|
snippets (->> (db/list-snippets)
|
||||||
(sort-by :pub-date)
|
(sort-by :pub-date)
|
||||||
(reverse)
|
(reverse))]
|
||||||
|
|
||||||
|
(if (nil? options)
|
||||||
|
(map serialize-snippet snippets)
|
||||||
|
(->> snippets
|
||||||
(drop skip)
|
(drop skip)
|
||||||
(take limit)
|
(take limit)
|
||||||
(map serialize-snippet)))))
|
(map serialize-snippet)))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue