diff --git a/backend/src/app/storage.clj b/backend/src/app/storage.clj index 218835149..10e289b7e 100644 --- a/backend/src/app/storage.clj +++ b/backend/src/app/storage.clj @@ -274,7 +274,7 @@ (let [min-age (db/interval min-age) rows (db/exec! conn [sql:retrieve-deleted-objects-chunk min-age cursor])] [(some-> rows peek :created-at) - (some->> (seq rows) (d/group-by' #(-> % :backend keyword) :id) seq)])) + (some->> (seq rows) (d/group-by #(-> % :backend keyword) :id #{}) seq)])) (retrieve-deleted-objects [conn] (->> (d/iteration (fn [cursor] @@ -383,7 +383,7 @@ (mapv #(d/update-when % :metadata db/decode-transit-pgobject)))] (when (seq rows) [(-> rows peek :created-at) - (d/group-by' get-bucket :id rows)]))) + (d/group-by get-bucket :id #{} rows)]))) (retrieve-touched [conn] (->> (d/iteration (fn [cursor] diff --git a/common/src/app/common/data.cljc b/common/src/app/common/data.cljc index eb74bd3a4..08c952d93 100644 --- a/common/src/app/common/data.cljc +++ b/common/src/app/common/data.cljc @@ -597,19 +597,10 @@ (defn group-by - ([kf coll] (group-by kf identity coll)) - ([kf vf coll] - (let [conj (fnil conj [])] - (reduce (fn [result item] - (update result (kf item) conj (vf item))) - {} - coll)))) - -(defn group-by' - "A variant of group-by that uses a set for collecting results." - ([kf coll] (group-by kf identity coll)) - ([kf vf coll] - (let [conj (fnil conj #{})] + ([kf coll] (group-by kf identity [] coll)) + ([kf vf coll] (group-by kf vf [] coll)) + ([kf vf iv coll] + (let [conj (fnil conj iv)] (reduce (fn [result item] (update result (kf item) conj (vf item))) {}