Skip to content

Commit

Permalink
Merge branch 'develop' into sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
ericplaquevent committed Jan 12, 2022
2 parents 4a2fc92 + e71e2b6 commit 8dc610d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 27 deletions.
1 change: 0 additions & 1 deletion server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
TABLES_CORRESPONDANCE_ACCESS_KEY_ID=
TABLES_CORRESPONDANCE_SECRET_ACCESS_KEY=
TABLES_CORRESPONDANCE_ONISEP_FILE=
TABLES_CORRESPONDANCE_RNCP_XML_FILE=
TABLES_CORRESPONDANCE_CONVENTION_FILES_PATH=
TABLES_CORRESPONDANCES_API_ENTREPRISE_KEY=
TABLES_CORRESPONDANCE_ONISEP_EMAIL=
Expand Down
8 changes: 0 additions & 8 deletions server/src/http/routes/etablissement.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,5 @@ module.exports = () => {
})
);

router.get(
"/etablissements/siret-uai",
tryCatch(async (req, res) => {
const { data } = await axios.get(`${CATALOGUE_API_URL}/entity/etablissements/siret-uai`, { params: req.query });
return res.json(data);
})
);

return router;
};
21 changes: 3 additions & 18 deletions server/src/logic/services/etablissementService.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ const { diffEtablissement } = require("../../common/utils/diffUtils");

const apiCfaDock = require("../../common/apis/apiCfaDock");

/*
* Build updates history
*/
const buildUpdatesHistory = (etablissement, updates, keys) => {
const from = keys.reduce((acc, key) => {
acc[key] = etablissement[key];
return acc;
}, {});
return [...(etablissement.updates_history ?? []), { from, to: { ...updates }, updated_at: Date.now() }];
};

const parseErrors = (messages) => {
if (!messages) {
return "";
Expand All @@ -29,7 +18,7 @@ const parseErrors = (messages) => {

const etablissementService = async (
etablissement,
{ withHistoryUpdate = true, scope = { siret: true, geoloc: true, conventionnement: true, onisep: true } } = {}
{ scope = { siret: true, geoloc: true, conventionnement: true, onisep: true } } = {}
) => {
try {
let error = null;
Expand Down Expand Up @@ -173,14 +162,10 @@ const etablissementService = async (
...updatedEtablissement,
};

const published = !updatedEtablissement.ferme && updatedEtablissement.api_entreprise_reference;
updatedEtablissement.published = published;
updatedEtablissement.published = !updatedEtablissement.ferme && updatedEtablissement.api_entreprise_reference;

const { updates, keys } = diffEtablissement(etablissement, updatedEtablissement);
const { updates } = diffEtablissement(etablissement, updatedEtablissement);
if (updates) {
if (withHistoryUpdate) {
updatedEtablissement.updates_history = buildUpdatesHistory(etablissement, updates, keys);
}
return { updates, etablissement: updatedEtablissement };
}
}
Expand Down

0 comments on commit 8dc610d

Please sign in to comment.