Skip to content

Commit

Permalink
AE-2274: Refactor liite deletion to use the same pattern as others
Browse files Browse the repository at this point in the history
  • Loading branch information
solita-juhohaa committed Oct 16, 2024
1 parent 001ade1 commit 59f8710
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@
(when (file/file-exists? aws-s3-client file-key)
(delete-from-s3 aws-s3-client file-key))))

(defn- delete-energiatodistus-liite [db aws-s3-client liite]
(let [liite-id (:id liite)]
(defn- delete-energiatodistus-liite [db aws-s3-client liite-id]
(energiatodistus-destruction-db/destroy-liite! db {:liite_id liite-id})
(delete-energiatodistus-liite-s3 aws-s3-client liite-id)
(energiatodistus-destruction-db/destroy-liite-audit! db {:liite_id liite-id})))
(energiatodistus-destruction-db/destroy-liite-audit! db {:liite_id liite-id}))

(defn- destroy-energiatodistus-liitteet [db aws-s3-client energiatodistus-id]
(let [liitteet (energiatodistus-destruction-db/select-to-be-destroyed-liitteet-by-energiatodistus-id db {:energiatodistus_id energiatodistus-id})]
(let [liitteet (map :liite-id (energiatodistus-destruction-db/select-to-be-destroyed-liitteet-by-energiatodistus-id db {:energiatodistus_id energiatodistus-id}))]
(mapv #(delete-energiatodistus-liite db aws-s3-client %) liitteet)))

(defn- destroy-viesti! [db viesti-id]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ from vo_toimenpide
where energiatodistus_id = :energiatodistus_id;

-- name: select-to-be-destroyed-liitteet-by-energiatodistus-id
select id
select id as liite_id
from liite
where energiatodistus_id = :energiatodistus_id;

Expand Down

0 comments on commit 59f8710

Please sign in to comment.