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 {
|
||||
url: {{host}}/api/snippets?limit=2&skip=0
|
||||
url: {{host}}/api/snippets?limit=100&skip=0
|
||||
body: none
|
||||
auth: none
|
||||
}
|
||||
|
||||
params:query {
|
||||
limit: 2
|
||||
limit: 100
|
||||
skip: 0
|
||||
}
|
||||
|
||||
headers {
|
||||
~Accept: application/edn
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"title": "Test Snippet",
|
||||
|
|
|
|||
|
|
@ -10,13 +10,15 @@
|
|||
(assoc snippet :pub-date (.toString (:pub-date snippet)))))
|
||||
|
||||
(defn view-snippets [options]
|
||||
(if (nil? options)
|
||||
(map serialize-snippet (db/list-snippets))
|
||||
(let [limit (:limit options)
|
||||
skip (:skip options)]
|
||||
(->> (db/list-snippets)
|
||||
(sort-by :pub-date)
|
||||
(reverse)
|
||||
(let [limit (:limit options)
|
||||
skip (:skip options)
|
||||
snippets (->> (db/list-snippets)
|
||||
(sort-by :pub-date)
|
||||
(reverse))]
|
||||
|
||||
(if (nil? options)
|
||||
(map serialize-snippet snippets)
|
||||
(->> snippets
|
||||
(drop skip)
|
||||
(take limit)
|
||||
(map serialize-snippet)))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue