Skip to content

Commit

Permalink
refactor: remove useless assets (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineRelief authored Aug 30, 2024
1 parent 1826c95 commit 8f6dbeb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 58 deletions.
4 changes: 2 additions & 2 deletions src/routes/download/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ router.post('/records', async (req, res) => {
await sendEmail({
message: {
to: req.context.user.username,
subject: `${params.application} - Your data export is completed - ${params.fileName}`, // TODO : put in config for 1.3
html: 'Dear colleague,\n\nPlease find attached to this e-mail the requested data export.\n\nFor any issues with the data export, please contact [email protected]\n\n Best regards,\[email protected]', // TODO : put in config for 1.3
subject: `${params.application} - Your data export is completed - ${params.fileName}`,
html: 'Dear colleague,\n\nPlease find attached to this e-mail the requested data export.\n\nFor any issues with the data export, please contact your manager.',
attachments,
},
});
Expand Down
71 changes: 15 additions & 56 deletions src/server/pullJobScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,66 +148,25 @@ const fetchRecordsServiceToService = (
token: string
): void => {
const apiConfiguration: ApiConfiguration = pullJob.apiConfiguration;
// Hard coded for EIOS due to specific behavior
const EIOS_ORIGIN = 'https://portal.who.int/eios/';
// === HARD CODED ENDPOINTS ===
const headers: any = {
Authorization: 'Bearer ' + token,
};
// Hardcoded specific behavior for EIOS
if (apiConfiguration.endpoint.startsWith(EIOS_ORIGIN)) {
// === HARD CODED ENDPOINTS ===
const boardsUrl = 'GetBoards?tags=signal+app';
const articlesUrl = 'GetPinnedArticles';
axios({
url: apiConfiguration.endpoint + boardsUrl,
method: 'get',
headers,
})
.then(({ data }) => {
if (data && data.result) {
const boardIds = data.result.map((x) => x.id);
axios({
url: `${apiConfiguration.endpoint}${articlesUrl}?boardIds=${boardIds}`,
method: 'get',
headers,
})
.then(({ data: data2 }) => {
if (data2 && data2.result) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
insertRecords(data2.result, pullJob, true, false);
}
})
.catch((err) => {
logger.error(
`Job ${pullJob.name} : Failed to get pinned articles : ${err}`
);
});
}
})
.catch((err) => {
logger.error(
`Job ${pullJob.name} : Failed to get signal app boards : ${err}`
);
});
} else {
// Generic case
axios({
url: apiConfiguration.endpoint + pullJob.url,
method: 'get',
headers,
// Generic case
axios({
url: apiConfiguration.endpoint + pullJob.url,
method: 'get',
headers,
})
.then(({ data }) => {
const records = pullJob.path ? get(data, pullJob.path) : data;
if (records) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
insertRecords(records, pullJob, false, false);
}
})
.then(({ data }) => {
const records = pullJob.path ? get(data, pullJob.path) : data;
if (records) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
insertRecords(records, pullJob, false, false);
}
})
.catch((err) => {
logger.error(`Job ${pullJob.name} : Failed to fetch data : ${err}`);
});
}
.catch((err) => {
logger.error(`Job ${pullJob.name} : Failed to fetch data : ${err}`);
});
};

/**
Expand Down

0 comments on commit 8f6dbeb

Please sign in to comment.