-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Re #1629] We were misusing the result of the DB query to update an organisation, as we were using the affected rows number as it was the organisation's updated id, that was being passed to the function to associate tags with the organisation. Hence, we have ended-up associating those tags to the organisation with id = `1` (UNEP). Besides, since we no longer have organisations with id `-1` to handle GPML membership process, we don't need at all to update an id of an organisation there, which is quite risky as well. So, now we avoid that and we also make sure we use the entity's domain properties, removing the ones that are not expected to be updated in each case. Finally, we also provide the right `organisation` id coming from the Path params of the endpoint for making the tags associations. In order to perform the mentioned changes easier, we have refactored the update code to be dynamic and not harcode the updated params. For that we have followed a similar approach as for the resource update query, adding DB functions declarations as well.
- Loading branch information
1 parent
d5a0967
commit dc8c5d8
Showing
5 changed files
with
77 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,27 @@ | ||
(ns gpml.db.organisation | ||
{:ns-tracker/resource-deps ["organisation.sql"]} | ||
(:require [hugsql.core :as hugsql])) | ||
(:require [gpml.util :as util] | ||
[gpml.util.sql :as sql-util] | ||
[hugsql.core :as hugsql])) | ||
|
||
(hugsql/def-db-fns "gpml/db/organisation.sql") | ||
(declare update-organisation | ||
organisation-by-id | ||
all-public-entities | ||
all-public-non-member-entities | ||
all-non-members | ||
new-organisation | ||
all-members | ||
organisation-tags | ||
geo-coverage-v2 | ||
get-organisation-files-to-migrate | ||
get-organisations) | ||
|
||
(hugsql/def-db-fns "gpml/db/organisation.sql" {:quoting :ansi}) | ||
|
||
(defn organisation->db-organisation | ||
"Apply transformations to Organisation entity fields to database specific | ||
types." | ||
[resource] | ||
(-> resource | ||
(util/update-if-not-nil :geo_coverage_type sql-util/keyword->pg-enum "geo_coverage_type") | ||
(util/update-if-not-nil :review_status sql-util/keyword->pg-enum "review_status"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters