Skip to content

Commit

Permalink
Azure timer bugfixing.
Browse files Browse the repository at this point in the history
  • Loading branch information
jheretic committed Jul 1, 2021
1 parent 4a8141d commit 37826d7
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"ms-azuretools.vscode-azurefunctions"
]
}
6 changes: 6 additions & 0 deletions europepmcUpload/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"schedule": "0 0 3 * * *",
"name": "europepmcUpload",
"type": "timerTrigger",
"direction": "in"
}
30 changes: 22 additions & 8 deletions src/index.js → europepmcUpload/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const getPreprints = async () => {
try {
const response = await fetch(url);
const data = await response.json();
return data;
return data.data;
} catch (error) {
console.log('oh dear, looks like we broke the preprints fetch: ', error);
}
Expand Down Expand Up @@ -129,11 +129,25 @@ const uploadToEuropePMC = async () => {
client.close();
};

buildXML()
.then(() => {
if (FTP_USER && FTP_PASS) {
uploadToEuropePMC();
module.exports = function(context, europepmcUpload) {
if (europepmcUpload && europepmcUpload.IsPastDue && context) {
context.log('Upload is running late!');
}
buildXML()
.then(() => {
if (FTP_USER && FTP_PASS) {
uploadToEuropePMC();
}
return;
})
.catch((err) => console.error('Failed to export:', err));
if (context) {
if (europepmcUpload && europepmcUpload.IsPastDue) {
context.log('Upload is running late!');
}
return;
})
.catch((err) => console.error('Failed to export:', err));
const timestamp = new Date().toISOString();
context.log('Upload ran!', timestamp);
}
};


15 changes: 15 additions & 0 deletions host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}
7 changes: 7 additions & 0 deletions local.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "node",
"AzureWebJobsStorage": ""
}
}
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
"doc": "docs"
},
"homepage": "https://github.com/throneless-tech/PREreview-feed",
"main": "./src/index.js",
"main": "./europepmcUpload/index.js",
"bin": {
"prereview-feed": "./src/index.js"
"prereview-feed": "./europepmcUpload/index.js"
},
"files": [
"./src/index.js"
"./europepmcUpload/index.js"
],
"scripts": {
"start": "npx ./src/index.js",
"lint": "eslint --ignore-path .gitignore --ext js --fix ./src"
"start": "npx ./europepmcUpload/index.js",
"lint": "eslint --ignore-path .gitignore --ext js --fix ./feed"
},
"engines": {
"node": ">=12.0"
Expand Down Expand Up @@ -94,6 +94,7 @@
"prettier": "^2.1.0"
},
"dependencies": {
"basic-ftp": "^4.6.6",
"feed": "^4.2.1",
"node-fetch": "^2.6.0",
"xmlbuilder2": "^2.3.1"
Expand Down

0 comments on commit 37826d7

Please sign in to comment.