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 {
|
meta {
|
||||||
name: delete_snippet
|
name: delete_snippet
|
||||||
type: http
|
type: http
|
||||||
seq: 5
|
seq: 6
|
||||||
}
|
}
|
||||||
|
|
||||||
delete {
|
delete {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
meta {
|
meta {
|
||||||
name: get_snippet_by_slug
|
name: get_snippet
|
||||||
type: http
|
type: http
|
||||||
seq: 10
|
seq: 5
|
||||||
}
|
}
|
||||||
|
|
||||||
get {
|
get {
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
meta {
|
meta {
|
||||||
name: ping
|
name: ping
|
||||||
type: http
|
type: http
|
||||||
seq: 1
|
seq: 2
|
||||||
}
|
}
|
||||||
|
|
||||||
get {
|
get {
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,9 @@
|
||||||
new-tags (get raw-patch :tags '[])
|
new-tags (get raw-patch :tags '[])
|
||||||
existing-tags (get snippet :snippet/tags '[])
|
existing-tags (get snippet :snippet/tags '[])
|
||||||
tags-to-remove (vec (set/difference (set existing-tags) (set new-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})]
|
patch (merge (to-update raw-patch) {:db/id eid})]
|
||||||
(t/log! {:level :info, :data {:patch patch :retracts retracts :slug slug :eid eid}} "Patching snippet")
|
(t/log! {:level :info, :data {:patch patch :retracts retracts :slug slug :eid eid}} "Patching snippet")
|
||||||
(when (nil? eid)
|
(when (nil? eid)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@
|
||||||
"Converts snippet pub-date to ISO-8601 string for EDN serialization"
|
"Converts snippet pub-date to ISO-8601 string for EDN serialization"
|
||||||
[snippet]
|
[snippet]
|
||||||
(when 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]
|
(defn view-snippets [options]
|
||||||
(let [limit (:limit options)
|
(let [limit (:limit options)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue