Skip to content
Snippets Groups Projects
Commit 96fae1f8 authored by Yuci Gou's avatar Yuci Gou
Browse files

Merge branch 'shared-data-model' of gitlab.coko.foundation:xpub/xpub-epmc into shared-data-model

parents 4bfd9893 91a0e66a
No related branches found
No related tags found
2 merge requests!114Shared data model,!115Dev
......@@ -11,6 +11,9 @@
# fromNcbi
*/30 * * * * node server/ncbi-integration/fromNcbi
# privacy notice check
30 2 * * * node server/privacyNotice/privacyNoticeCheck
# check for published manuscripts
*/30 * * * * node server/ncbi-integration/publishedCheck
......@@ -22,4 +25,3 @@
# always leave an empty line at the end of the file
......@@ -2,6 +2,8 @@
// const toNcbi = require('../ncbi-integration/toNcbi')
// const fromNcbi = require('../ncbi-integration/fromNcbi')
// const privacyNoticeCheck = require('../privacyNotice/privacyNoticeCheck')
module.exports = jobs => {
// cron.schedule('*/1 * * * *', () => {
// toNcbi()
......@@ -9,4 +11,7 @@ module.exports = jobs => {
// cron.schedule('*/1 * * * *', () => {
// fromNcbi()
// })
// cron.schedule('*/1 * * * *', () => {
// privacyNoticeCheck()
// })
}
const https = require('https')
const PrivacyNoticeManager = require('../xpub-model/entities/privacyNotice')
const privacyNoticeCheck = () => {
PrivacyNoticeManager.findLastVersion().then(privacyNotice => {
getLatestVersion().then(data => {
const privacyNotesData = data.nodes[0].node
if (privacyNotesData['version Count'] !== privacyNotice.version) {
const latestPrivacyNotice = {
version: privacyNotesData['version Count'],
effectiveDate: new Date(
privacyNotesData.changed.split('-')[0].trim(),
),
}
PrivacyNoticeManager.save(latestPrivacyNotice)
}
})
})
}
function getLatestVersion() {
return new Promise((resolve, reject) => {
https
.get(
'https://www.ebi.ac.uk/data-protection/privacy-notice/json/5d182831-5e99-4072-816b-380cda5f58df',
res => {
res.setEncoding('utf8')
let data = ''
res.on('data', chunk => {
data += chunk
})
res.on('end', () => {
resolve(JSON.parse(data))
res = null
})
},
)
.on('error', err => {
// Handle errors
reject(err)
})
})
}
;(() => {
privacyNoticeCheck()
})()
module.export = privacyNoticeCheck
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment