allow for deleting all tags on a snippet
This commit is contained in:
parent
9c0b8bef3c
commit
aeefd4a157
5 changed files with 10 additions and 6 deletions
|
|
@ -1,7 +1,7 @@
|
|||
meta {
|
||||
name: delete_snippet
|
||||
type: http
|
||||
seq: 5
|
||||
seq: 6
|
||||
}
|
||||
|
||||
delete {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
meta {
|
||||
name: get_snippet_by_slug
|
||||
name: get_snippet
|
||||
type: http
|
||||
seq: 10
|
||||
seq: 5
|
||||
}
|
||||
|
||||
get {
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
meta {
|
||||
name: ping
|
||||
type: http
|
||||
seq: 1
|
||||
seq: 2
|
||||
}
|
||||
|
||||
get {
|
||||
|
|
|
|||
|
|
@ -163,7 +163,9 @@
|
|||
new-tags (get raw-patch :tags '[])
|
||||
existing-tags (get snippet :snippet/tags '[])
|
||||
tags-to-remove (vec (set/difference (set existing-tags) (set new-tags)))
|
||||
retracts (map #(vector :db/retract eid :snippet/tags %) tags-to-remove)
|
||||
retracts (if (nil? (:tags raw-patch))
|
||||
nil
|
||||
(map #(vector :db/retract eid :snippet/tags %) tags-to-remove))
|
||||
patch (merge (to-update raw-patch) {:db/id eid})]
|
||||
(t/log! {:level :info, :data {:patch patch :retracts retracts :slug slug :eid eid}} "Patching snippet")
|
||||
(when (nil? eid)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@
|
|||
"Converts snippet pub-date to ISO-8601 string for EDN serialization"
|
||||
[snippet]
|
||||
(when snippet
|
||||
(assoc snippet :pub-date (.toString (:pub-date snippet)))))
|
||||
(-> snippet
|
||||
(assoc :tags (if (nil? (:tags snippet)) '[] (:tags snippet)))
|
||||
(assoc :pub-date (.toString (:pub-date snippet))))))
|
||||
|
||||
(defn view-snippets [options]
|
||||
(let [limit (:limit options)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue