diff --git a/app/config/index.js b/app/config/index.js index 266de87f4..bba132878 100644 --- a/app/config/index.js +++ b/app/config/index.js @@ -22,7 +22,7 @@ module.exports = Object.freeze({ // App config winston: ResProvider.winston(), database: ResProvider.database(), - syncTaskAtStart: process.env['RCT_SYNC_TASK_AT_START']?.trim().toLowerCase() === 'true' ? process.env['RCT_SYNC_TASK_AT_START'] : false, + syncTaskAtStart: ResProvider.envOrDef('RCT_SYNC_TASK_AT_START', false, Boolean), databasePersistance: require('./databasePersistance.js'), public: require('./public.js'), @@ -38,5 +38,5 @@ module.exports = Object.freeze({ stack: (logger, er) => logger.error(er.stack), object: (logger, er) => logger.error(JSON.stringify(er, null, 2)), }, - defaultErrorsLogginDepth: process.env['RCT_ERR_DEPTH']?.length() > 0 ? process.env['RCT_ERR_DEPTH'] : 'object', + defaultErrorsLogginDepth: ResProvider.envOrDef('RCT_ERR_DEPTH', 'object'), }); diff --git a/app/config/services.js b/app/config/services.js index 5a6388e2c..1ce1ec7b8 100644 --- a/app/config/services.js +++ b/app/config/services.js @@ -31,6 +31,10 @@ const services = { mcDetTag: ResProvider.getServiceEndpoint('ML_MC_TAG'), }, }, + + batchSize: { + ML: ResProvider.envOrDef('RCT_ML_BATCH_SIZE', 2), + }, }; /* diff --git a/app/lib/ResProvider.js b/app/lib/ResProvider.js index d70140ca5..d888c15f0 100644 --- a/app/lib/ResProvider.js +++ b/app/lib/ResProvider.js @@ -59,6 +59,13 @@ class ResProvider { return res; } + static envOrDef(name, def, castType = String) { + if (castType == Boolean) { + return process.env[name]?.length > 0 ? Boolean(process.env[name] == 'true') : def; + } + return process.env[name]?.length > 0 ? castType(process.env[name]) : def; + } + static areDesiredValuesPresent(obj, objDefinition) { for (const key of Object.values(objDefinition)) { if (!obj[key]) { diff --git a/app/lib/alimonitor-services/AbstractServiceSynchronizer.js b/app/lib/alimonitor-services/AbstractServiceSynchronizer.js index 32061d87b..b5392ad9d 100644 --- a/app/lib/alimonitor-services/AbstractServiceSynchronizer.js +++ b/app/lib/alimonitor-services/AbstractServiceSynchronizer.js @@ -201,6 +201,7 @@ class AbstractServiceSynchronizer { } else { await this.makeSequentialRequest(data); } + this.monitor.logResults(); } catch (fatalError) { this.logger.error(fatalError.stack); diff --git a/app/lib/alimonitor-services/BookkeepingService.js b/app/lib/alimonitor-services/BookkeepingService.js index 70195ffe2..5196515fe 100644 --- a/app/lib/alimonitor-services/BookkeepingService.js +++ b/app/lib/alimonitor-services/BookkeepingService.js @@ -24,9 +24,7 @@ const EndpintFormatter = require('./ServicesEndpointsFormatter.js'); class BookkeepingService extends AbstractServiceSynchronizer { constructor() { super(); - this.batchedRequestes = true; this.batchSize = 100; - this.omitWhenCached = false; this.ketpFields = { id: 'ali-bk-id', diff --git a/app/lib/alimonitor-services/MonalisaService.js b/app/lib/alimonitor-services/MonalisaService.js index d6183873c..097532564 100644 --- a/app/lib/alimonitor-services/MonalisaService.js +++ b/app/lib/alimonitor-services/MonalisaService.js @@ -23,9 +23,7 @@ const config = require('../config/configProvider.js'); class MonalisaService extends AbstractServiceSynchronizer { constructor() { super(); - this.batchedRequestes = true; - this.batchSize = 5; - this.omitWhenCached = false; + this.batchSize = config.services.batchSize.ML; this.ketpFields = { name: 'name', @@ -92,8 +90,6 @@ class MonalisaService extends AbstractServiceSynchronizer { const q1 = await dbClient.query(pgCommand); const q2 = await this.monalisaServiceDetails.sync(d); return Promise.all([q1, q2]); - // eslint-disable-next-line capitalized-comments - // return await Promise.all([dbClient.query(pgCommand), this.monalisaServiceDetails.sync(d)]); } extractPeriod(rowData) { diff --git a/app/lib/alimonitor-services/MonalisaServiceDetails.js b/app/lib/alimonitor-services/MonalisaServiceDetails.js index 1b9a2c8b8..cd5c9191f 100644 --- a/app/lib/alimonitor-services/MonalisaServiceDetails.js +++ b/app/lib/alimonitor-services/MonalisaServiceDetails.js @@ -20,9 +20,7 @@ const EndpointsFormatter = require('./ServicesEndpointsFormatter.js'); class MonalisaServiceDetails extends AbstractServiceSynchronizer { constructor() { super(); - this.batchedRequestes = true; this.batchSize = 5; - this.omitWhenCached = false; this.ketpFields = { run_no: 'run_number', diff --git a/app/lib/alimonitor-services/MonalisaServiceMC.js b/app/lib/alimonitor-services/MonalisaServiceMC.js index 342cb4122..bd3c231ab 100644 --- a/app/lib/alimonitor-services/MonalisaServiceMC.js +++ b/app/lib/alimonitor-services/MonalisaServiceMC.js @@ -23,8 +23,7 @@ class MonalisaServiceMC extends AbstractServiceSynchronizer { constructor() { super(); - this.batchedRequestes = true; - this.batchSize = 5; + this.batchSize = config.services.batchSize.ML; this.ketpFields = { name: 'name', diff --git a/app/lib/alimonitor-services/MonalisaServiceMCDetails.js b/app/lib/alimonitor-services/MonalisaServiceMCDetails.js index cbab74569..5e25f32bb 100644 --- a/app/lib/alimonitor-services/MonalisaServiceMCDetails.js +++ b/app/lib/alimonitor-services/MonalisaServiceMCDetails.js @@ -21,7 +21,6 @@ class MonalisaServiceMCDetails extends AbstractServiceSynchronizer { constructor() { super(); - this.batchedRequestes = true; this.batchSize = 5; this.keptFields = {