Commit 7d627ac5 authored by Audrey Hamelers's avatar Audrey Hamelers
parent 80ccb701
Pipeline #13002 passed with stages
in 5 minutes and 30 seconds
......@@ -2,7 +2,7 @@
\t on
\pset format unaligned
SELECT json_agg(t) FROM (SELECT date_revised "dateRevised", "updated", "created", journal_title "journalTitle", "meta,publisher_name" "meta,publisherName", "meta,issn", "meta,nlmta", "meta,nlmuniqueid", "meta,pubmed_status" "meta,pubmedStatus", "meta,pmc_status" "meta,pmcStatus", "meta,first_year" "meta,firstYear", "meta,end_year" "meta,endYear" FROM journal) t \g journals.json
SELECT json_agg(t) FROM (SELECT "updated", "created", journal_title "journalTitle", "meta,publisher_name" "meta,publisherName", "meta,issn", "meta,nlmta", "meta,nlmuniqueid", "meta,pmjrid", "meta,pubmed_status" "meta,pubmedStatus", "meta,pmc_status" "meta,pmcStatus", "meta,first_year" "meta,firstYear", "meta,end_year" "meta,endYear" FROM journal) t \g journals.json
-- exit psql and the container and run `docker cp xpubepmc_postgres_1:/journals.json config/journals.json`
-- push the result to git if necessary
\ No newline at end of file
# populate journals table from NCBI service
0 5 * * 0,3 APP_NAME=populate-journal node --harmony-promise-finally server/populate-journal/api.js
0 4 * * 0,3 APP_NAME=populate-journal node --harmony-promise-finally server/populate-journal/api.js
# Pdf converter polling
*/2 * * * * APP_NAME=pdf-conversion node server/pdf-conversion/api
......
......@@ -141,6 +141,13 @@ function createManifest(tmpPath, manuscript) {
articleIds && articleIds.find(id => id.pubIdType === 'pmid')
? articleIds.find(id => id.pubIdType === 'pmid').id
: 0
const submitter = manuscript.teams.find(t => t.roleName === 'submitter')
const subUser = submitter && submitter.users[0] && submitter.users[0]
const identity = subUser && subUser.identities[0]
const isPublisher = identity.meta && identity.meta.publisher
const epubPublisher = isPublisher && isPublisher === 'NPG'
const createdDate = moment(manuscript.created).format('YYYY-MM-DD')
const pubDates = manuscript['meta,publicationDates']
const releaseDelay = manuscript['meta,releaseDelay']
......@@ -152,18 +159,14 @@ function createManifest(tmpPath, manuscript) {
const ppubDate =
pubDates.find(date => date.type === 'ppub') &&
pubDates.find(date => date.type === 'ppub').date
const publisher = manuscript.journal['meta,publisherName']
const startDate =
(publisher.match(/Nature.*Pub.*Group/) && epubDate && epubDate) ||
(epubPublisher && epubDate && epubDate) ||
(ppubDate && ppubDate) ||
(epubDate && epubDate)
const publishDate = moment(startDate)
.add(releaseDelay, 'M')
.format('YYYY-MM-DD')
const submitter = manuscript.teams.find(t => t.roleName === 'submitter')
const subUser = submitter && submitter.users[0] && submitter.users[0]
const identity = subUser && subUser.identities[0]
const isPublisher = identity.meta && identity.meta.publisher
const journalNlmId = manuscript.journal['meta,nlmuniqueid']
const files = getNcbiFiles(manuscript)
const hasPubPdf = files.find(file => file.type === 'pdf4load') ? '1' : '0'
......
This diff is collapsed.
......@@ -20,12 +20,12 @@ class Journal extends EpmcBaseModel {
id: { type: 'uuid' },
created: { type: 'timestamp' },
updated: { type: ['timestamp', 'null'] },
dateRevised: { type: ['timestamp', 'null'] },
journalTitle: { type: 'string' },
'meta,publisherName': { type: ['string', 'null'] },
'meta,issn': { type: ['string', 'null'] },
'meta,nlmta': { type: ['string', 'null'] },
'meta,nlmuniqueid': { type: ['string', 'null'] },
'meta,pmjrid': { type: ['string', 'null'] },
'meta,pmcStatus': { type: 'boolean' },
'meta,pubmedStatus': { type: 'boolean' },
'meta,firstYear': { type: 'string' },
......@@ -119,9 +119,7 @@ class Journal extends EpmcBaseModel {
const update = knex('journal')
.update(journal)
.whereRaw(
`journal."meta,nlmuniqueid" = '${
journal['meta,nlmuniqueid']
}' AND journal.date_revised < '${journal.dateRevised}'`,
`journal."meta,nlmuniqueid" = '${journal['meta,nlmuniqueid']}'`,
)
const query = util.format(
'%s ON CONFLICT ("meta,nlmuniqueid") DO UPDATE SET %s',
......
exports.up = (knex, Promise) =>
knex.schema.table('journal', t => {
t.string('meta,pmjrid').unique()
t.dropColumn('date_revised')
})
exports.down = (knex, Promise) =>
knex.schema.table('manuscript', t => {
t.dropColumn('meta,pmjrid')
})
Markdown is supported
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