From 5edbd3683c13df86b4523b1fa5b6752f3ace4605 Mon Sep 17 00:00:00 2001 From: Audrey Hamelers <hamelers@ebi.ac.uk> Date: Mon, 21 Jun 2021 15:42:36 +0100 Subject: [PATCH] #1192 --- app/components/manage-site/operations.js | 1 + server/job-runner/index.js | 4 +++- server/xpub-model/entities/config/data-access.js | 1 + .../migrations/20210621153226_add-last-run.js | 9 +++++++++ server/xpub-model/seeds/jobs_seed.js | 16 ++++++++++++++++ .../entities/config/typeDefs.graphqls | 6 ++++-- 6 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 server/xpub-model/migrations/20210621153226_add-last-run.js diff --git a/app/components/manage-site/operations.js b/app/components/manage-site/operations.js index 39d4fbef1..4b89573ef 100644 --- a/app/components/manage-site/operations.js +++ b/app/components/manage-site/operations.js @@ -8,6 +8,7 @@ export const JOB_LIST = gql` running lastStatus lastPass + lastRun } } ` diff --git a/server/job-runner/index.js b/server/job-runner/index.js index 97f162071..2896a3bee 100644 --- a/server/job-runner/index.js +++ b/server/job-runner/index.js @@ -67,11 +67,13 @@ const checkJobStatus = async (name, logic, ftp) => { status = 'fail' } // Update status when job completes (or fails) + const date = new Date().toISOString() return JobManager.update({ name, running: false, lastStatus: status, - lastPass: status === 'pass' ? new Date().toISOString() : lastPass, + lastPass: status === 'pass' ? date : lastPass, + lastRun: date, }) } diff --git a/server/xpub-model/entities/config/data-access.js b/server/xpub-model/entities/config/data-access.js index 18d2196ad..8375b241c 100644 --- a/server/xpub-model/entities/config/data-access.js +++ b/server/xpub-model/entities/config/data-access.js @@ -17,6 +17,7 @@ class Job extends EpmcBaseModel { running: { type: 'boolean' }, lastStatus: { type: 'string', enum: ['pass', 'fail'] }, lastPass: { type: 'timestamp' }, + lastRun: { type: 'timestamp' }, frequency: { type: 'string', format: 'regex', diff --git a/server/xpub-model/migrations/20210621153226_add-last-run.js b/server/xpub-model/migrations/20210621153226_add-last-run.js new file mode 100644 index 000000000..67cdf2735 --- /dev/null +++ b/server/xpub-model/migrations/20210621153226_add-last-run.js @@ -0,0 +1,9 @@ +exports.up = (knex, Promise) => + knex.schema.table('config.job', t => { + t.timestamp('last_run') + }) + +exports.down = (knex, Promise) => + knex.schema.table('config.job', t => { + t.dropColumn('last_run') + }) diff --git a/server/xpub-model/seeds/jobs_seed.js b/server/xpub-model/seeds/jobs_seed.js index bd4c83fd5..97a221a4d 100644 --- a/server/xpub-model/seeds/jobs_seed.js +++ b/server/xpub-model/seeds/jobs_seed.js @@ -10,6 +10,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '0 1 * * *', description: 'Sends tagging and XML QA alert/receipt emails', }, @@ -18,6 +19,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '0 1 * * *', description: 'Attempts to complete citations of submissions with PMIDs', }, @@ -26,6 +28,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '0 2 * * * ', description: 'Adds citation information to XML before sending to repositories', @@ -35,6 +38,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '0 3 * * * ', description: 'Sends complete submission packets to the NCBI', }, @@ -43,6 +47,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '0 4 * * *', description: 'Sends removal requests to the NCBI', }, @@ -51,6 +56,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '0 6 * * *', description: 'Retrieves submission success and failure messages from the NCBI', @@ -60,6 +66,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '0 7 * * *', description: 'Checks and sends grant links to the EBI', }, @@ -68,6 +75,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '0 7 * * *', description: 'Notifies users of their stalled manuscript submissions', }, @@ -76,6 +84,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '0 18 * * *', description: 'Checks whether complete submissions are live on Europe PMC', }, @@ -84,6 +93,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '0 20 * * *', description: 'Checks for special, infrequent actions and performs as needed', @@ -93,6 +103,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '30 2 * * *', description: 'Checks and updates the privacy notice version number', }, @@ -101,6 +112,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '30 11 * * *', description: 'Checks for and mirrors changes to linked ORCID IDs', }, @@ -109,6 +121,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '0 5 * * 0,3', description: 'Updates the local NLM Catalog-based journal list', }, @@ -117,6 +130,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '*/1 * * * *', description: 'Runs checks to send and recieve files from NCBI PDF converter', @@ -126,6 +140,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '*/3 * * * *', description: 'Retrieves bulk upload files from FTP', }, @@ -134,6 +149,7 @@ exports.seed = async (knex, Promise) => { running: false, last_status: 'pass', last_pass: midnight, + last_run: midnight, frequency: '*/3 * * * *', description: 'Retrieves tagger files from FTP', }, diff --git a/server/xpub-server/entities/config/typeDefs.graphqls b/server/xpub-server/entities/config/typeDefs.graphqls index d090aaa75..4fcca09bd 100644 --- a/server/xpub-server/entities/config/typeDefs.graphqls +++ b/server/xpub-server/entities/config/typeDefs.graphqls @@ -4,14 +4,16 @@ type Job { running: Boolean! lastStatus: String lastPass: DateTime + lastRun: DateTime frequency: String! } input JobInput { name: String! running: Boolean - last_status: String - last_pass: DateTime + lastStatus: String + lastPass: DateTime + lastRun: DateTime } type Property { -- GitLab