Skip to content

Commit

Permalink
Merge pull request #260 from bcgsc/release/v7.16.2
Browse files Browse the repository at this point in the history
Release/v7.16.2
  • Loading branch information
Nithriel authored Jul 5, 2023
2 parents 846f14b + 8447a11 commit 755ad6e
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 32 deletions.
3 changes: 2 additions & 1 deletion app/routes/report/kbMatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ router.route('/:kbMatch([A-z0-9-]{36})')

router.route('/')
.get(async (req, res) => {
const {query: {matchedCancer, approvedTherapy, category}} = req;
const {query: {matchedCancer, approvedTherapy, category, iprEvidenceLevel}} = req;

// Check cache
const key = generateKey(`/reports/${req.report.ident}/kb-matches`, req.query);
Expand All @@ -79,6 +79,7 @@ router.route('/')
const results = await db.models.kbMatches.scope('public').findAll({
where: {
reportId: req.report.id,
...((iprEvidenceLevel) ? {iprEvidenceLevel: {[Op.in]: iprEvidenceLevel.split(',')}} : {}),
...((category) ? {category: {[Op.in]: category.split(',')}} : {}),
...((typeof matchedCancer === 'boolean') ? {matchedCancer} : {}),
...((typeof approvedTherapy === 'boolean') ? {approvedTherapy} : {}),
Expand Down
19 changes: 0 additions & 19 deletions app/routes/report/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ const createReport = require('../../libs/createReport');
const {parseReportSortQuery} = require('../../libs/queryOperations');
const db = require('../../models');
const logger = require('../../log');
const cache = require('../../cache');
const {getUserProjects} = require('../../libs/helperFunctions');

const {generateKey} = require('../../libs/cacheFunctions');
const {hasAccessToNonProdReports} = require('../../libs/helperFunctions');

const reportMiddleware = require('../../middleware/report');
Expand Down Expand Up @@ -158,19 +156,6 @@ router.route('/')
}
}

// Generate cache key
const key = (req.query.role) ? null : generateKey('/reports', req.query, {projectAccess: projects});

try {
const cacheResults = await cache.get(key);
if (cacheResults) {
res.type('json');
return res.send(cacheResults);
}
} catch (error) {
logger.error(`Error while checking cache for reports ${error}`);
}

// Generate options for report query
const opts = {
where: {
Expand Down Expand Up @@ -252,10 +237,6 @@ router.route('/')
const reports = await db.models.report.scope('public').findAndCountAll(opts);
const results = {total: reports.count, reports: reports.rows};

if (key) {
cache.set(key, JSON.stringify(results), 'EX', 14400);
}

return res.json(results);
} catch (error) {
logger.error(`Unable to lookup reports ${error}`);
Expand Down
2 changes: 1 addition & 1 deletion app/routes/report/variants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const logger = require('../../log');
const {KB_PIVOT_MAPPING} = require('../../constants');

const KBMATCHEXCLUDE = ['id', 'reportId', 'variantId', 'deletedAt', 'updatedBy'];
const MUTATION_REGEX = '^([^\\s]+)(\\s)mutation[s]?$';
const MUTATION_REGEX = '^([^\\s]+)(\\s)(mutation[s]?)?(missense)?$';

const getVariants = async (tableName, variantType, reportId) => {
return db.models[tableName].scope('extended').findAll({
Expand Down
19 changes: 12 additions & 7 deletions app/routes/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4421,16 +4421,21 @@
}
},
{
"name": "rapidTable",
"name": "category",
"in": "query",
"required": false,
"description": "Filter according to chosen rapidTable",
"description": "Filter by category field. Comma separated field",
"schema": {
"type": "string",
"enum": [
"therapeuticAssociation",
"cancerRelevance"
]
"type": "string"
}
},
{
"name": "iprEvidenceLevel",
"in": "query",
"required": false,
"description": "Filter by iprEvidenceLevel field. Comma separated field",
"schema": {
"type": "string"
}
}
],
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "ipr-api",
"version": "7.16.1",
"version": "7.16.2",
"description": "Integrated Pipeline Reports API",
"main": "bin/server.js",
"scripts": {
Expand Down
24 changes: 24 additions & 0 deletions test/routes/report/kbMatches.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('/reports/{REPORTID}/kb-matches', () => {
let variant;
let kbMatch;
let createData;
let createDataFilteringTest;

beforeAll(async () => {
// Get genomic template
Expand All @@ -69,9 +70,19 @@ describe('/reports/{REPORTID}/kb-matches', () => {
variantId: variant.id,
category: 'unknown',
variantType: 'cnv',
iprEvidenceLevel: 'IPR-A',
};

createDataFilteringTest = {
reportId: report.id,
variantId: variant.id,
category: 'unknown',
variantType: 'cnv',
iprEvidenceLevel: 'IPR-B',
};

kbMatch = await db.models.kbMatches.create(createData);
await db.models.kbMatches.create(createDataFilteringTest);
}, LONGER_TIMEOUT);

describe('GET', () => {
Expand All @@ -86,6 +97,19 @@ describe('/reports/{REPORTID}/kb-matches', () => {
checkKbMatch(res.body[0]);
});

test('Filtering kb-matches is ok', async () => {
const res = await request
.get(`/api/reports/${report.ident}/kb-matches`)
.query({iprEvidenceLevel: 'IPR-A,IPR-C'})
.auth(username, password)
.type('json')
.expect(HTTP_STATUS.OK);

expect(Array.isArray(res.body)).toBe(true);
checkKbMatch(res.body[0]);
res.body.every((match) => {return expect(match.iprEvidenceLevel).toEqual('IPR-A');});
});

test('Getting a specific kb-match is ok', async () => {
const res = await request
.get(`/api/reports/${report.ident}/kb-matches/${kbMatch.ident}`)
Expand Down
2 changes: 1 addition & 1 deletion test/routes/report/variants.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ describe('/reports/{REPORTID}/kb-matches', () => {
category: 'therapeutic',
variantType: 'mut',
iprEvidenceLevel: 'IPR-A',
kbVariant: 'geneX mutation',
kbVariant: 'geneX missense',
matchedCancer: true,
};

Expand Down

0 comments on commit 755ad6e

Please sign in to comment.