diff --git a/app/libs/createReport.js b/app/libs/createReport.js index 4f38d0123..9682089e1 100644 --- a/app/libs/createReport.js +++ b/app/libs/createReport.js @@ -76,12 +76,14 @@ const createReportKbMatchSection = async (reportId, modelName, sectionContent, o variantType: record.variantType, variantId: record.variantId, kbVariant: record.kbVariant, + kbVariantId: record.kbVariantId, }; const statementCopy = {...record}; delete statementCopy.variantType; delete statementCopy.variantId; delete statementCopy.kbVariant; + delete statementCopy.kbVariantId; statementData = [{...statementCopy}]; } diff --git a/app/models/reports/kbMatchJoin.js b/app/models/reports/kbMatchJoin.js index ce2e7daf4..1195cf30f 100644 --- a/app/models/reports/kbMatchJoin.js +++ b/app/models/reports/kbMatchJoin.js @@ -38,6 +38,16 @@ module.exports = (sequelize, Sq) => { }, }, }, + indexes: [ + { + name: 'idx_kb_match_id_join', + fields: ['kb_match_id'], + }, + { + name: 'idx_kb_matched_statement_id_join', + fields: ['kb_matched_statement_id'], + }, + ], }, ); }; diff --git a/app/routes/variantText/variantText.js b/app/routes/variantText/variantText.js index 9c53a5c78..e8b3466bd 100644 --- a/app/routes/variantText/variantText.js +++ b/app/routes/variantText/variantText.js @@ -203,6 +203,10 @@ router.route('/') delete req.body.project; delete req.body.template; + if (typeof req.body.cancerType === 'string') { + req.body.cancerType = [req.body.cancerType]; + } + await validateAgainstSchema(createSchema, req.body); } catch (error) { const message = `Error while validating variant text create request ${error}`; diff --git a/migrations/20241112210700-DEVSU-2457-fix-id-sequence.js b/migrations/20241112210700-DEVSU-2457-fix-id-sequence.js new file mode 100644 index 000000000..03548f9e7 --- /dev/null +++ b/migrations/20241112210700-DEVSU-2457-fix-id-sequence.js @@ -0,0 +1,10 @@ +module.exports = { + up: async (queryInterface) => { + // eslint-disable-next-line max-len + queryInterface.sequelize.query('SELECT setval(\'reports_kb_matches_id_seq\', (SELECT MAX(id) FROM reports_kb_matches) + 1);'); + }, + + down: async () => { + throw new Error('Not Implemented!'); + }, +}; diff --git a/migrations/20241112211455-DEVSU-2483-add-kb-match-index.js b/migrations/20241112211455-DEVSU-2483-add-kb-match-index.js new file mode 100644 index 000000000..20ac2e91c --- /dev/null +++ b/migrations/20241112211455-DEVSU-2483-add-kb-match-index.js @@ -0,0 +1,14 @@ +module.exports = { + up: async (queryInterface) => { + await queryInterface.addIndex('reports_kb_match_join', ['kb_match_id'], { + name: 'idx_kb_match_id_join', + }); + await queryInterface.addIndex('reports_kb_match_join', ['kb_matched_statement_id'], { + name: 'idx_kb_matched_statement_id_join', + }); + }, + + down: async () => { + throw new Error('Not Implemented!'); + }, +}; diff --git a/test/testData/mockReportData.json b/test/testData/mockReportData.json index affb4c5e0..04144bbbf 100644 --- a/test/testData/mockReportData.json +++ b/test/testData/mockReportData.json @@ -256,6 +256,7 @@ "variantType": "exp", "variant": "hash12345678", "kbVariant": "protein increased expression", + "kbVariantId": "123321", "category": "cancer predisposition", "disease": "colorectal cancer", "relevance": "unfavourable",