Skip to content

Commit

Permalink
remove atoms in funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaeng72 committed Dec 20, 2024
1 parent 21e23aa commit 66cba06
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 24 deletions.
16 changes: 4 additions & 12 deletions search-app/src/cmr/search/api/association.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@
"When given a list of response entities, will set the http response status of each response entity based on its content.
Ex) If the response entity contains an error message, will set the status as 400."
[list]
(let [new-list (atom '())]
(doseq [map-item list]
(if (or (contains? map-item :errors) (contains? map-item :warning))
(swap! new-list conj (assoc map-item :status 400))
(swap! new-list conj (assoc map-item :status 200))))
(reverse @new-list)))
(map #(assoc % :status (if (or (:errors %) (:warning %)) 400 200))
list))

(defn- api-response
"Creates an association response with the given data response"
Expand All @@ -39,13 +35,9 @@
:headers {"Content-Type" mt/json}})))

(defn num-errors-in-assoc-results
"Counts num of errors in association-results"
"Counts the number of errors in association-results"
[results]
(let [err-count (atom 0)]
(doseq [item results]
(if (contains? item :errors)
(swap! err-count inc)))
@err-count))
(count (filter :errors results)))

(defn association-results->status-code
"Check for concept-types requiring error status to be returned.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,4 @@

(defn add-individual-statuses
[list]
(let [new-list (atom '())]
(doseq [map-item list]
(if (or (contains? map-item :errors) (contains? map-item :warning))
(swap! new-list conj (assoc map-item :status 400))
(swap! new-list conj (assoc map-item :status 200))))
(reverse @new-list)))
(map #(assoc % :status (if (or (:errors %) (:warning %)) 400 200)) list))
8 changes: 2 additions & 6 deletions system-int-test/src/cmr/system_int_test/utils/tag_util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,8 @@

(defn add-individual-statuses
[list]
(let [new-list (atom '())]
(doseq [map-item list]
(if (or (contains? map-item :errors) (contains? map-item :warning))
(swap! new-list conj (assoc map-item :status 400))
(swap! new-list conj (assoc map-item :status 200))))
(reverse @new-list)))
[list]
(map #(assoc % :status (if (or (:errors %) (:warning %)) 400 200)) list))

(defn assert-tag-association-response-mixed?
"Assert the tag association response when status code is 207 multi-status response."
Expand Down

0 comments on commit 66cba06

Please sign in to comment.