diff --git a/server/app.js b/server/app.js index 671c6fce52081f95c9805c4fca031c80e59c68ae..b2a0fa4132e832c7edc971ca66a7d194f40c77eb 100644 --- a/server/app.js +++ b/server/app.js @@ -20,11 +20,17 @@ const compression = require('compression') const EventEmitter = require('events') const gqlApi = require('./graphql') +console.log('process.version') +console.log(process.version) + const configureApp = app => { const models = require('@pubsweet/models') const authsome = require('pubsweet-server/src/helpers/authsome') // TODO: Fix import app.use(compression()) + console.log('process.version') + console.log(process.version) + app.locals.models = models app.use(bodyParser.json({ limit: '50mb' })) diff --git a/server/model-manuscript/src/graphql.js b/server/model-manuscript/src/graphql.js index cb154642b1cc9a7de3a3133f60fcaadeea100025..66fccc2025707a0173f890cee03c3c2319832bda 100644 --- a/server/model-manuscript/src/graphql.js +++ b/server/model-manuscript/src/graphql.js @@ -299,71 +299,71 @@ const resolvers = { } } - if (process.env.INSTANCE_NAME === 'ncrc') { - // eslint-disable-next-line - const submissionForm = require('../../../app/storage/forms-ncrc/submit.json') - const spreadsheetId = '1OvWJj7ZTFhniC4KbFNbskuYSNMftsG2ocKuY-i9ezVA' - - const fieldsOrder = submissionForm.children - .filter(el => el.name) - .map(formElement => formElement.name.split('.')[1]) - - const formatSubmissionData = rawSubmissionData => { - return Object.keys(rawSubmissionData).reduce((acc, key) => { - return { ...acc, [key]: rawSubmissionData[key].toString() } - }, {}) - } - - const publishArticleInGoogleSheets = async submissionData => { - const formattedSubmissionData = formatSubmissionData(submissionData) - - const { articleURL } = formattedSubmissionData - const doc = new GoogleSpreadsheet(spreadsheetId) - - await doc.useServiceAccountAuth({ - client_email: credentials.client_email, - private_key: credentials.private_key, - }) - - await doc.loadInfo() - const sheet = doc.sheetsByIndex[0] - const rows = await sheet.getRows() - - const indexOfExistingArticle = rows.findIndex( - row => row.articleURL === articleURL, - ) - - if (indexOfExistingArticle !== -1) { - fieldsOrder.forEach(fieldName => { - rows[indexOfExistingArticle][fieldName] = - formattedSubmissionData[fieldName] || '' - }) - await rows[indexOfExistingArticle].save() - } else { - await sheet.addRow({ ...formattedSubmissionData }) - } - } - - try { - await publishArticleInGoogleSheets(manuscript.submission) - - const updatedManuscript = await ctx.models.Manuscript.query().updateAndFetchById( - id, - { - published: new Date(), - status: 'published', - }, - ) - - return updatedManuscript - } catch (e) { - // eslint-disable-next-line - console.log('error while publishing in google spreadsheet') - // eslint-disable-next-line - console.log(e) - return null - } - } + // if (process.env.INSTANCE_NAME === 'ncrc') { + // // eslint-disable-next-line + // const submissionForm = require('../../../app/storage/forms-ncrc/submit.json') + // const spreadsheetId = '1OvWJj7ZTFhniC4KbFNbskuYSNMftsG2ocKuY-i9ezVA' + + // const fieldsOrder = submissionForm.children + // .filter(el => el.name) + // .map(formElement => formElement.name.split('.')[1]) + + // const formatSubmissionData = rawSubmissionData => { + // return Object.keys(rawSubmissionData).reduce((acc, key) => { + // return { ...acc, [key]: rawSubmissionData[key].toString() } + // }, {}) + // } + + // const publishArticleInGoogleSheets = async submissionData => { + // const formattedSubmissionData = formatSubmissionData(submissionData) + + // const { articleURL } = formattedSubmissionData + // const doc = new GoogleSpreadsheet(spreadsheetId) + + // await doc.useServiceAccountAuth({ + // client_email: credentials.client_email, + // private_key: credentials.private_key, + // }) + + // await doc.loadInfo() + // const sheet = doc.sheetsByIndex[0] + // const rows = await sheet.getRows() + + // const indexOfExistingArticle = rows.findIndex( + // row => row.articleURL === articleURL, + // ) + + // if (indexOfExistingArticle !== -1) { + // fieldsOrder.forEach(fieldName => { + // rows[indexOfExistingArticle][fieldName] = + // formattedSubmissionData[fieldName] || '' + // }) + // await rows[indexOfExistingArticle].save() + // } else { + // await sheet.addRow({ ...formattedSubmissionData }) + // } + // } + + // try { + // await publishArticleInGoogleSheets(manuscript.submission) + + // const updatedManuscript = await ctx.models.Manuscript.query().updateAndFetchById( + // id, + // { + // published: new Date(), + // status: 'published', + // }, + // ) + + // return updatedManuscript + // } catch (e) { + // // eslint-disable-next-line + // console.log('error while publishing in google spreadsheet') + // // eslint-disable-next-line + // console.log(e) + // return null + // } + // } if (!manuscript.published && process.env.INSTANCE_NAME === 'aperture') { manuscript = ctx.models.Manuscript.query().updateAndFetchById(id, {