From 73437dc6e4094daa157619cca5cafe943e68f1af Mon Sep 17 00:00:00 2001 From: Curtis Upshall Date: Fri, 9 Feb 2024 11:18:56 -0800 Subject: [PATCH 01/10] SIMSBIOHUB-459: Fixed save taxonomy repo method --- api/src/repositories/taxonomy-repository.ts | 65 +++++++++++---------- api/src/services/taxonomy-service.ts | 15 +++-- 2 files changed, 45 insertions(+), 35 deletions(-) diff --git a/api/src/repositories/taxonomy-repository.ts b/api/src/repositories/taxonomy-repository.ts index 20f42142..aeb2fc0b 100644 --- a/api/src/repositories/taxonomy-repository.ts +++ b/api/src/repositories/taxonomy-repository.ts @@ -1,9 +1,11 @@ import SQL from 'sql-template-strings'; import { z } from 'zod'; import { getKnex } from '../database/db'; -import { ApiExecuteSQLError } from '../errors/api-error'; +import { getLogger } from '../utils/logger'; import { BaseRepository } from './base-repository'; +const defaultLog = getLogger('repositories/taxonomy-repository'); + export const TaxonRecord = z.object({ taxon_id: z.number(), itis_tsn: z.number(), @@ -60,40 +62,43 @@ export class TaxonomyRepository extends BaseRepository { itisTsn: number, itisScientificName: string, commonName: string | null, - itisData: Record, + itisData: Record, itisUpdateDate: string - ): Promise { + ): Promise { + defaultLog.debug({ label: 'addItisTaxonRecord', itisTsn }); + const sqlStatement = SQL` - INSERT INTO - taxon - ( - itis_tsn, - itis_scientific_name, - common_name, - itis_data, - itis_update_date - ) - VALUES ( - ${itisTsn}, - ${itisScientificName}, - ${commonName}, - ${itisData}, - ${itisUpdateDate} + WITH inserted_row AS ( + INSERT INTO + taxon + ( + itis_tsn, + itis_scientific_name, + common_name, + itis_data, + itis_update_date + ) + VALUES ( + ${itisTsn}, + ${itisScientificName}, + ${commonName}, + ${itisData}, + ${itisUpdateDate} + ) + ON CONFLICT + DO NOTHING + RETURNING * ) - RETURNING - *; + SELECT * FROM inserted_row + UNION + SELECT * FROM taxon + WHERE + taxon.itis_tsn = 93 + AND + taxon.record_end_date IS null; `; - const response = await this.connection.sql(sqlStatement, TaxonRecord); - - if (response.rowCount !== 1) { - throw new ApiExecuteSQLError('Failed to insert new taxon record', [ - 'TaxonomyRepository->addItisTaxonRecord', - 'rowCount was null or undefined, expected rowCount = 1' - ]); - } - - return response.rows[0]; + await this.connection.sql(sqlStatement, TaxonRecord); } /** diff --git a/api/src/services/taxonomy-service.ts b/api/src/services/taxonomy-service.ts index 3d49ad8c..6c01e876 100644 --- a/api/src/services/taxonomy-service.ts +++ b/api/src/services/taxonomy-service.ts @@ -1,7 +1,10 @@ import { IDBConnection } from '../database/db'; import { TaxonomyRepository, TaxonRecord } from '../repositories/taxonomy-repository'; +import { getLogger } from '../utils/logger'; import { ItisService, ItisSolrSearchResponse } from './itis-service'; +const defaultLog = getLogger('services/taxonomy-service'); + export type TaxonSearchResult = { tsn: number; commonName: string | null; @@ -29,11 +32,13 @@ export class TaxonomyService { * @memberof TaxonomyService */ async getTaxonByTsnIds(tsnIds: number[]): Promise { + defaultLog.debug({ label: 'getTaxonByTsnIds', tsnIds }); + // Search for taxon records in the database const existingTaxonRecords = await this.taxonRepository.getTaxonByTsnIds(tsnIds); - let patchedTaxonRecords: TaxonRecord[] = []; + const existingTsnIds = existingTaxonRecords.map((record) => record.itis_tsn); - const missingTsnIds = tsnIds.filter((tsnId) => !existingTaxonRecords.find((item) => item.itis_tsn === tsnId)); + const missingTsnIds = tsnIds.filter((tsnId) => !existingTsnIds.includes(tsnId)); if (missingTsnIds.length) { // If the local database does not contain a record for all of the requested ids, search ITIS for the missing @@ -41,11 +46,11 @@ export class TaxonomyService { const itisService = new ItisService(); const itisResponse = await itisService.searchItisByTSN(missingTsnIds); - patchedTaxonRecords = await Promise.all(itisResponse.map(async (item) => this.addItisTaxonRecord(item))); + await Promise.all(itisResponse.map(this.addItisTaxonRecord)); } // Missing ids patched, return taxon records for all requested ids - return this._sanitizeTaxonRecordsData(existingTaxonRecords.concat(patchedTaxonRecords)); + return this._sanitizeTaxonRecordsData(await this.taxonRepository.getTaxonByTsnIds(tsnIds)); } _sanitizeTaxonRecordsData(taxonRecords: TaxonRecord[]): TaxonSearchResult[] { @@ -65,7 +70,7 @@ export class TaxonomyService { * @return {*} {Promise} * @memberof TaxonomyService */ - async addItisTaxonRecord(itisSolrResponse: ItisSolrSearchResponse): Promise { + async addItisTaxonRecord(itisSolrResponse: ItisSolrSearchResponse): Promise { let commonName = null; if (itisSolrResponse.commonNames) { commonName = itisSolrResponse.commonNames[0].split('$')[1]; From e0ad738127e9c5ba07f6666941c38c63d85ab3c3 Mon Sep 17 00:00:00 2001 From: Curtis Upshall Date: Fri, 9 Feb 2024 11:39:37 -0800 Subject: [PATCH 02/10] SIMSBIOHUB-459: Updated tests --- .../repositories/taxonomy-repository.test.ts | 18 +------ api/src/services/taxonomy-service.test.ts | 50 +++++-------------- 2 files changed, 15 insertions(+), 53 deletions(-) diff --git a/api/src/repositories/taxonomy-repository.test.ts b/api/src/repositories/taxonomy-repository.test.ts index 348654b9..6e410da8 100644 --- a/api/src/repositories/taxonomy-repository.test.ts +++ b/api/src/repositories/taxonomy-repository.test.ts @@ -47,7 +47,7 @@ describe('TaxonomyRepository', () => { }); describe('addItisTaxonRecord', () => { - it('should return a new taxon record', async () => { + it('should return undefined on successful insert', async () => { const mockQueryResponse = { rowCount: 1, rows: [ @@ -75,21 +75,7 @@ describe('TaxonomyRepository', () => { const response = await taxonomyRepository.addItisTaxonRecord(1, 'string', 'string', {}, 'string'); - expect(response).to.be.eql({ - taxon_id: 1, - itis_tsn: 1, - bc_taxon_code: 'string', - itis_scientific_name: 'string', - common_name: 'string', - itis_data: {}, - record_effective_date: 'string', - record_end_date: 'string', - create_date: 'string', - create_user: 1, - update_date: 'string', - update_user: 1, - revision_count: 1 - }); + expect(response).to.be.eql(undefined); }); }); diff --git a/api/src/services/taxonomy-service.test.ts b/api/src/services/taxonomy-service.test.ts index bb6af9df..9bb1aa15 100644 --- a/api/src/services/taxonomy-service.test.ts +++ b/api/src/services/taxonomy-service.test.ts @@ -62,7 +62,7 @@ describe('TaxonomyService', () => { const response = await taxonomyService.getTaxonByTsnIds([1]); - expect(repo).to.be.calledOnce; + expect(repo).to.be.calledTwice; expect(response).to.be.eql([{ tsn: 1, commonName: 'common_name', scientificName: 'itis_scientific_name' }]); }); @@ -104,19 +104,24 @@ describe('TaxonomyService', () => { const taxonomyService = new TaxonomyService(mockDBConnection); - const repo = sinon.stub(TaxonomyRepository.prototype, 'getTaxonByTsnIds').resolves([getTaxonRecord[0]]); + const getTaxonByTsnIdsStub = sinon + .stub(TaxonomyRepository.prototype, 'getTaxonByTsnIds') + .onCall(0) + .resolves([getTaxonRecord[0]]) + .onCall(1) + .resolves([...getTaxonRecord]); const searchItisByTSNStub = sinon .stub(ItisService.prototype, 'searchItisByTSN') .resolves(getItisSolrSearchResponse); - const itisService = sinon.stub(TaxonomyService.prototype, 'addItisTaxonRecord').resolves(getTaxonRecord[1]); + const addItisTaxonRecordStub = sinon.stub(TaxonomyService.prototype, 'addItisTaxonRecord').resolves(); const response = await taxonomyService.getTaxonByTsnIds([1, 2]); - expect(repo).to.be.calledOnce; + expect(getTaxonByTsnIdsStub).to.be.calledTwice; expect(searchItisByTSNStub).to.be.calledOnce; - expect(itisService).to.be.calledOnce; + expect(addItisTaxonRecordStub).to.be.calledOnce; expect(response).to.be.eql([ { tsn: 1, commonName: 'common_name', scientificName: 'itis_scientific_name' }, { tsn: 2, commonName: 'common_name', scientificName: 'itis_scientific_name' } @@ -130,40 +135,11 @@ describe('TaxonomyService', () => { const taxonomyService = new TaxonomyService(mockDBConnection); - const addItisTaxonRecordStub = sinon.stub(TaxonomyRepository.prototype, 'addItisTaxonRecord').resolves({ - taxon_id: 1, - itis_tsn: 1, - bc_taxon_code: null, - itis_scientific_name: 'scientificName', - common_name: 'commonName', - itis_data: {}, - record_effective_date: 'updateDate', - record_end_date: null, - create_date: 'now', - create_user: 1, - update_date: null, - update_user: null, - revision_count: 1 - }); - - const response = await taxonomyService.addItisTaxonRecord(getItisSolrSearchResponse[0]); + const addItisTaxonRecordStub = sinon.stub(TaxonomyRepository.prototype, 'addItisTaxonRecord').resolves(); + + await taxonomyService.addItisTaxonRecord(getItisSolrSearchResponse[0]); expect(addItisTaxonRecordStub).to.be.calledOnce; - expect(response).to.be.eql({ - taxon_id: 1, - itis_tsn: 1, - bc_taxon_code: null, - itis_scientific_name: 'scientificName', - common_name: 'commonName', - itis_data: {}, - record_effective_date: 'updateDate', - record_end_date: null, - create_date: 'now', - create_user: 1, - update_date: null, - update_user: null, - revision_count: 1 - }); }); }); From b74a7e7938d8b81f2561d873dd3c5c88b3e489fd Mon Sep 17 00:00:00 2001 From: Curtis Upshall Date: Fri, 9 Feb 2024 11:45:37 -0800 Subject: [PATCH 03/10] SIMSBIOHUB-459: Fixed typo --- api/src/repositories/taxonomy-repository.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/repositories/taxonomy-repository.ts b/api/src/repositories/taxonomy-repository.ts index aeb2fc0b..617d2438 100644 --- a/api/src/repositories/taxonomy-repository.ts +++ b/api/src/repositories/taxonomy-repository.ts @@ -93,7 +93,7 @@ export class TaxonomyRepository extends BaseRepository { UNION SELECT * FROM taxon WHERE - taxon.itis_tsn = 93 + taxon.itis_tsn = ${itisTsn} AND taxon.record_end_date IS null; `; From 5df8cbd65f286b6fad765bfe296e75d877980346 Mon Sep 17 00:00:00 2001 From: Kjartan Date: Fri, 9 Feb 2024 17:22:01 -0800 Subject: [PATCH 04/10] fix addItisTaxonRecord function call --- api/src/services/taxonomy-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/services/taxonomy-service.ts b/api/src/services/taxonomy-service.ts index 6c01e876..f6eb6463 100644 --- a/api/src/services/taxonomy-service.ts +++ b/api/src/services/taxonomy-service.ts @@ -46,7 +46,7 @@ export class TaxonomyService { const itisService = new ItisService(); const itisResponse = await itisService.searchItisByTSN(missingTsnIds); - await Promise.all(itisResponse.map(this.addItisTaxonRecord)); + await Promise.all(itisResponse.map(async (item) => this.addItisTaxonRecord(item))); } // Missing ids patched, return taxon records for all requested ids From 687c01c9d8f4f994d8228aaa44eb6bf3eea8a9ef Mon Sep 17 00:00:00 2001 From: Curtis Upshall Date: Mon, 12 Feb 2024 10:02:51 -0800 Subject: [PATCH 05/10] SIMSBIOHUB-459: Amended taxon insert logic --- api/src/repositories/taxonomy-repository.ts | 14 ++++++++++++-- api/src/services/taxonomy-service.ts | 8 +++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/api/src/repositories/taxonomy-repository.ts b/api/src/repositories/taxonomy-repository.ts index 617d2438..c055ffe9 100644 --- a/api/src/repositories/taxonomy-repository.ts +++ b/api/src/repositories/taxonomy-repository.ts @@ -3,6 +3,7 @@ import { z } from 'zod'; import { getKnex } from '../database/db'; import { getLogger } from '../utils/logger'; import { BaseRepository } from './base-repository'; +import { ApiExecuteSQLError } from '../errors/api-error'; const defaultLog = getLogger('repositories/taxonomy-repository'); @@ -64,7 +65,7 @@ export class TaxonomyRepository extends BaseRepository { commonName: string | null, itisData: Record, itisUpdateDate: string - ): Promise { + ): Promise { defaultLog.debug({ label: 'addItisTaxonRecord', itisTsn }); const sqlStatement = SQL` @@ -98,7 +99,16 @@ export class TaxonomyRepository extends BaseRepository { taxon.record_end_date IS null; `; - await this.connection.sql(sqlStatement, TaxonRecord); + const response = await this.connection.sql(sqlStatement, TaxonRecord); + + if (response.rowCount !== 1) { + throw new ApiExecuteSQLError('Failed to insert new taxon record', [ + 'TaxonomyRepository->addItisTaxonRecord', + 'rowCount was null or undefined, expected rowCount = 1' + ]); + } + + return response.rows[0]; } /** diff --git a/api/src/services/taxonomy-service.ts b/api/src/services/taxonomy-service.ts index f6eb6463..5b24e759 100644 --- a/api/src/services/taxonomy-service.ts +++ b/api/src/services/taxonomy-service.ts @@ -40,17 +40,19 @@ export class TaxonomyService { const missingTsnIds = tsnIds.filter((tsnId) => !existingTsnIds.includes(tsnId)); + let patchedTaxonRecords: TaxonRecord[] = []; + if (missingTsnIds.length) { // If the local database does not contain a record for all of the requested ids, search ITIS for the missing // taxon records, patching the missing records in the local database in the process const itisService = new ItisService(); const itisResponse = await itisService.searchItisByTSN(missingTsnIds); - await Promise.all(itisResponse.map(async (item) => this.addItisTaxonRecord(item))); + patchedTaxonRecords = await Promise.all(itisResponse.map(async (item) => this.addItisTaxonRecord(item))); } // Missing ids patched, return taxon records for all requested ids - return this._sanitizeTaxonRecordsData(await this.taxonRepository.getTaxonByTsnIds(tsnIds)); + return this._sanitizeTaxonRecordsData(existingTaxonRecords.concat(patchedTaxonRecords)); } _sanitizeTaxonRecordsData(taxonRecords: TaxonRecord[]): TaxonSearchResult[] { @@ -70,7 +72,7 @@ export class TaxonomyService { * @return {*} {Promise} * @memberof TaxonomyService */ - async addItisTaxonRecord(itisSolrResponse: ItisSolrSearchResponse): Promise { + async addItisTaxonRecord(itisSolrResponse: ItisSolrSearchResponse): Promise { let commonName = null; if (itisSolrResponse.commonNames) { commonName = itisSolrResponse.commonNames[0].split('$')[1]; From c0da5e4b042290c5ec6dc3d96f8183c6d4ed17c0 Mon Sep 17 00:00:00 2001 From: Curtis Upshall Date: Mon, 12 Feb 2024 11:16:37 -0800 Subject: [PATCH 06/10] SIMSBIOHUB-459: Format fix --- api/src/repositories/taxonomy-repository.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/repositories/taxonomy-repository.ts b/api/src/repositories/taxonomy-repository.ts index c055ffe9..262b4e61 100644 --- a/api/src/repositories/taxonomy-repository.ts +++ b/api/src/repositories/taxonomy-repository.ts @@ -1,9 +1,9 @@ import SQL from 'sql-template-strings'; import { z } from 'zod'; import { getKnex } from '../database/db'; +import { ApiExecuteSQLError } from '../errors/api-error'; import { getLogger } from '../utils/logger'; import { BaseRepository } from './base-repository'; -import { ApiExecuteSQLError } from '../errors/api-error'; const defaultLog = getLogger('repositories/taxonomy-repository'); From ed941b61c282c02af9fa5fc937ff5eca3c4192af Mon Sep 17 00:00:00 2001 From: Curtis Upshall Date: Mon, 12 Feb 2024 11:23:04 -0800 Subject: [PATCH 07/10] SIMSBIOHUB-459: Revert test changes --- .../repositories/taxonomy-repository.test.ts | 18 ++++++- api/src/services/taxonomy-service.test.ts | 50 ++++++++++++++----- 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/api/src/repositories/taxonomy-repository.test.ts b/api/src/repositories/taxonomy-repository.test.ts index 6e410da8..348654b9 100644 --- a/api/src/repositories/taxonomy-repository.test.ts +++ b/api/src/repositories/taxonomy-repository.test.ts @@ -47,7 +47,7 @@ describe('TaxonomyRepository', () => { }); describe('addItisTaxonRecord', () => { - it('should return undefined on successful insert', async () => { + it('should return a new taxon record', async () => { const mockQueryResponse = { rowCount: 1, rows: [ @@ -75,7 +75,21 @@ describe('TaxonomyRepository', () => { const response = await taxonomyRepository.addItisTaxonRecord(1, 'string', 'string', {}, 'string'); - expect(response).to.be.eql(undefined); + expect(response).to.be.eql({ + taxon_id: 1, + itis_tsn: 1, + bc_taxon_code: 'string', + itis_scientific_name: 'string', + common_name: 'string', + itis_data: {}, + record_effective_date: 'string', + record_end_date: 'string', + create_date: 'string', + create_user: 1, + update_date: 'string', + update_user: 1, + revision_count: 1 + }); }); }); diff --git a/api/src/services/taxonomy-service.test.ts b/api/src/services/taxonomy-service.test.ts index 9bb1aa15..bb6af9df 100644 --- a/api/src/services/taxonomy-service.test.ts +++ b/api/src/services/taxonomy-service.test.ts @@ -62,7 +62,7 @@ describe('TaxonomyService', () => { const response = await taxonomyService.getTaxonByTsnIds([1]); - expect(repo).to.be.calledTwice; + expect(repo).to.be.calledOnce; expect(response).to.be.eql([{ tsn: 1, commonName: 'common_name', scientificName: 'itis_scientific_name' }]); }); @@ -104,24 +104,19 @@ describe('TaxonomyService', () => { const taxonomyService = new TaxonomyService(mockDBConnection); - const getTaxonByTsnIdsStub = sinon - .stub(TaxonomyRepository.prototype, 'getTaxonByTsnIds') - .onCall(0) - .resolves([getTaxonRecord[0]]) - .onCall(1) - .resolves([...getTaxonRecord]); + const repo = sinon.stub(TaxonomyRepository.prototype, 'getTaxonByTsnIds').resolves([getTaxonRecord[0]]); const searchItisByTSNStub = sinon .stub(ItisService.prototype, 'searchItisByTSN') .resolves(getItisSolrSearchResponse); - const addItisTaxonRecordStub = sinon.stub(TaxonomyService.prototype, 'addItisTaxonRecord').resolves(); + const itisService = sinon.stub(TaxonomyService.prototype, 'addItisTaxonRecord').resolves(getTaxonRecord[1]); const response = await taxonomyService.getTaxonByTsnIds([1, 2]); - expect(getTaxonByTsnIdsStub).to.be.calledTwice; + expect(repo).to.be.calledOnce; expect(searchItisByTSNStub).to.be.calledOnce; - expect(addItisTaxonRecordStub).to.be.calledOnce; + expect(itisService).to.be.calledOnce; expect(response).to.be.eql([ { tsn: 1, commonName: 'common_name', scientificName: 'itis_scientific_name' }, { tsn: 2, commonName: 'common_name', scientificName: 'itis_scientific_name' } @@ -135,11 +130,40 @@ describe('TaxonomyService', () => { const taxonomyService = new TaxonomyService(mockDBConnection); - const addItisTaxonRecordStub = sinon.stub(TaxonomyRepository.prototype, 'addItisTaxonRecord').resolves(); - - await taxonomyService.addItisTaxonRecord(getItisSolrSearchResponse[0]); + const addItisTaxonRecordStub = sinon.stub(TaxonomyRepository.prototype, 'addItisTaxonRecord').resolves({ + taxon_id: 1, + itis_tsn: 1, + bc_taxon_code: null, + itis_scientific_name: 'scientificName', + common_name: 'commonName', + itis_data: {}, + record_effective_date: 'updateDate', + record_end_date: null, + create_date: 'now', + create_user: 1, + update_date: null, + update_user: null, + revision_count: 1 + }); + + const response = await taxonomyService.addItisTaxonRecord(getItisSolrSearchResponse[0]); expect(addItisTaxonRecordStub).to.be.calledOnce; + expect(response).to.be.eql({ + taxon_id: 1, + itis_tsn: 1, + bc_taxon_code: null, + itis_scientific_name: 'scientificName', + common_name: 'commonName', + itis_data: {}, + record_effective_date: 'updateDate', + record_end_date: null, + create_date: 'now', + create_user: 1, + update_date: null, + update_user: null, + revision_count: 1 + }); }); }); From 9faa4c7493f96a5062c4c8811d907010afb75f86 Mon Sep 17 00:00:00 2001 From: Nick Phura Date: Mon, 12 Feb 2024 11:47:11 -0800 Subject: [PATCH 08/10] Reduce logging --- api/src/app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/app.ts b/api/src/app.ts index b69fad3b..bd51ea3a 100644 --- a/api/src/app.ts +++ b/api/src/app.ts @@ -28,7 +28,7 @@ const app: express.Express = express(); // Enable CORS app.use(function (req: Request, res: Response, next: NextFunction) { - defaultLog.info(`${req.method} ${req.url}`); + defaultLog.debug(`${req.method} ${req.url}`); res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Authorization, responseType'); res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE, HEAD'); From ae42bbb20541f8eee31bf0975d2e68f9b389014d Mon Sep 17 00:00:00 2001 From: Nick Phura Date: Mon, 12 Feb 2024 11:50:05 -0800 Subject: [PATCH 09/10] Reduce logging in dev/test --- api/.pipeline/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/.pipeline/config.js b/api/.pipeline/config.js index 677ebcfa..8cbe35c6 100644 --- a/api/.pipeline/config.js +++ b/api/.pipeline/config.js @@ -87,7 +87,7 @@ const phases = { s3KeyPrefix: (isStaticDeployment && 'biohub') || `local/${deployChangeId}/biohub`, tz: config.timezone.api, sso: config.sso.dev, - logLevel: 'debug', + logLevel: (isStaticDeployment && 'info') || 'debug', nodeOptions: '--max_old_space_size=1500', // 75% of memoryLimit (bytes) cpuRequest: '50m', cpuLimit: '500m', @@ -145,7 +145,7 @@ const phases = { s3KeyPrefix: 'biohub', tz: config.timezone.api, sso: config.sso.prod, - logLevel: 'info', + logLevel: 'warn', nodeOptions: '--max_old_space_size=1500', // 75% of memoryLimit (bytes) cpuRequest: '50m', cpuLimit: '1000m', From 3b294c5a4e78879b493cf475c251edc82ed48b16 Mon Sep 17 00:00:00 2001 From: Nick Phura Date: Mon, 12 Feb 2024 11:52:17 -0800 Subject: [PATCH 10/10] tweak deployed resources --- api/.pipeline/config.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/api/.pipeline/config.js b/api/.pipeline/config.js index 8cbe35c6..6bec4abc 100644 --- a/api/.pipeline/config.js +++ b/api/.pipeline/config.js @@ -88,12 +88,12 @@ const phases = { tz: config.timezone.api, sso: config.sso.dev, logLevel: (isStaticDeployment && 'info') || 'debug', - nodeOptions: '--max_old_space_size=1500', // 75% of memoryLimit (bytes) + nodeOptions: '--max_old_space_size=2250', // 75% of memoryLimit (bytes) cpuRequest: '50m', - cpuLimit: '500m', + cpuLimit: '600m', memoryRequest: '100Mi', - memoryLimit: '2Gi', - replicas: '1', + memoryLimit: '3Gi', + replicas: (isStaticDeployment && '1') || '1', replicasMax: (isStaticDeployment && '2') || '1' }, test: { @@ -117,13 +117,13 @@ const phases = { tz: config.timezone.api, sso: config.sso.test, logLevel: 'info', - nodeOptions: '--max_old_space_size=1500', // 75% of memoryLimit (bytes) + nodeOptions: '--max_old_space_size=2250', // 75% of memoryLimit (bytes) cpuRequest: '50m', cpuLimit: '1000m', memoryRequest: '100Mi', - memoryLimit: '2Gi', + memoryLimit: '3Gi', replicas: '2', - replicasMax: '3' + replicasMax: '4' }, prod: { namespace: 'a0ec71-prod', @@ -146,13 +146,13 @@ const phases = { tz: config.timezone.api, sso: config.sso.prod, logLevel: 'warn', - nodeOptions: '--max_old_space_size=1500', // 75% of memoryLimit (bytes) + nodeOptions: '--max_old_space_size=2250', // 75% of memoryLimit (bytes) cpuRequest: '50m', cpuLimit: '1000m', memoryRequest: '100Mi', - memoryLimit: '2Gi', + memoryLimit: '3Gi', replicas: '2', - replicasMax: '3' + replicasMax: '4' } };