From 81ae1cb37624c04b42e66382f48b09be845a3ea7 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Thu, 3 Mar 2022 18:40:34 -0500 Subject: [PATCH] fix: add current registry to validation --- src/tasks/sync-audit-table.js | 5 +++-- src/tasks/sync-organizations.js | 3 ++- src/tasks/sync-picklists.js | 3 ++- src/validations/projects.validations.js | 1 + tests/test-data/new-project.json | 1 + tests/test-data/update-project.json | 1 + 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/tasks/sync-audit-table.js b/src/tasks/sync-audit-table.js index 56b33ae9..1f94b0ca 100644 --- a/src/tasks/sync-audit-table.js +++ b/src/tasks/sync-audit-table.js @@ -1,5 +1,6 @@ import _ from 'lodash'; +import logUpdate from 'log-update'; import { SimpleIntervalJob, Task } from 'toad-scheduler'; import { Organization, Audit } from '../models'; import datalayer from '../datalayer'; @@ -8,7 +9,7 @@ import dotenv from 'dotenv'; dotenv.config(); const task = new Task('sync-audit', async () => { - console.log('Syncing Audit Information'); + logUpdate('Syncing Audit Information'); if (process.env.USE_SIMULATOR === 'false') { const organizations = await Organization.findAll({ raw: true }); await Promise.all( @@ -25,7 +26,7 @@ const job = new SimpleIntervalJob( const syncOrganizationAudit = async (organization) => { try { - console.log('Syncing Audit:', organization.name); + logUpdate('Syncing Audit:', organization.name); const rootHistory = await datalayer.getRootHistory(organization.registryId); const lastRootSaved = await Audit.findOne({ diff --git a/src/tasks/sync-organizations.js b/src/tasks/sync-organizations.js index a076e425..a9059140 100644 --- a/src/tasks/sync-organizations.js +++ b/src/tasks/sync-organizations.js @@ -1,10 +1,11 @@ +import logUpdate from 'log-update'; import { SimpleIntervalJob, Task } from 'toad-scheduler'; import { Organization } from '../models'; import dotenv from 'dotenv'; dotenv.config(); const task = new Task('sync-organizations', () => { - console.log('Subscribing to default organizations'); + logUpdate('Subscribing to default organizations'); if (process.env.USE_SIMULATOR === 'false') { Organization.subscribeToDefaultOrganizations(); } diff --git a/src/tasks/sync-picklists.js b/src/tasks/sync-picklists.js index 1ab77d7c..1b337e22 100644 --- a/src/tasks/sync-picklists.js +++ b/src/tasks/sync-picklists.js @@ -1,8 +1,9 @@ +import logUpdate from 'log-update'; import { SimpleIntervalJob, Task } from 'toad-scheduler'; import { pullPickListValues } from '../utils/data-loaders'; const task = new Task('sync-picklist', () => { - console.log('Syncing Picklist Values'); + logUpdate('Syncing Picklist Values'); pullPickListValues(); }); diff --git a/src/validations/projects.validations.js b/src/validations/projects.validations.js index 1998db19..4e98c680 100644 --- a/src/validations/projects.validations.js +++ b/src/validations/projects.validations.js @@ -15,6 +15,7 @@ export const baseSchema = { // warehouseProjectId - derived upon creation // orgUid - derived upon creation projectId: Joi.string().required(), + currentRegistry: Joi.string().required(), originProjectId: Joi.string().required(), registryOfOrigin: Joi.string() .custom(pickListValidation('registries', 'registryOfOrigin')) diff --git a/tests/test-data/new-project.json b/tests/test-data/new-project.json index c7121ddf..679c47c7 100644 --- a/tests/test-data/new-project.json +++ b/tests/test-data/new-project.json @@ -1,6 +1,7 @@ { "projectId": "c9d147e2-bc07-4e68-a76d-43424fa8cd4e", "registryOfOrigin": "Singapore National Registry", + "currentRegistry": "Singapore National Registry", "originProjectId": "Singapore National Registry", "program": "Restoration & Conservation", "projectName": "Sungei Buloh Wetlands Conservation", diff --git a/tests/test-data/update-project.json b/tests/test-data/update-project.json index e6b6d97e..f3988493 100644 --- a/tests/test-data/update-project.json +++ b/tests/test-data/update-project.json @@ -2,6 +2,7 @@ "projectId": "c9d147e2-bc07-4e68-a76d-43424fa8cd4e", "program": "UPDATED", "projectName": "UPDATED", + "currentRegistry": "Singapore National Registry", "registryOfOrigin": "Singapore National Registry", "originProjectId": "Singapore National Registry", "projectLink": "UPDATED",