Skip to content

Commit 52618cf

Browse files
committed
rename seqQC column to seqQc; add new table reports_seqqc
1 parent 0b2b121 commit 52618cf

7 files changed

Lines changed: 196 additions & 2 deletions

File tree

app/middleware/report.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ module.exports = async (req, res, next, ident) => {
3838
model: db.models.signatures.scope('public'),
3939
as: 'signatures',
4040
},
41+
{
42+
model: db.models.seqQC.scope('public'),
43+
as: 'seqQC',
44+
},
4145
];
4246

4347
let result;

app/models/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ patientInformation.belongsTo(analysisReports, {
113113
as: 'report', foreignKey: 'reportId', onDelete: 'CASCADE', onUpdate: 'CASCADE', constraints: true,
114114
});
115115

116+
// seqqc
117+
const seqQC = require('./reports/seqqc')(sequelize, Sq);
118+
119+
seqQC.belongsTo(analysisReports, {
120+
as: 'report', foreignKey: 'reportId', targetKey: 'id', onDelete: 'CASCADE', constraints: true,
121+
});
122+
analysisReports.hasMany(seqQC, {
123+
as: 'seqQC', foreignKey: 'reportId', onDelete: 'CASCADE', constraints: true,
124+
});
125+
116126
// Summary
117127
const summary = {};
118128
summary.variantCounts = require('./reports/genomic/summary/variantCounts')(sequelize, Sq);

app/models/reports/report.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ module.exports = (sequelize, Sq) => {
7676
},
7777
allowNull: false,
7878
},
79-
seqQC: {
79+
seqQc: {
80+
name: 'seqQc',
81+
field: 'seq_qc',
8082
type: Sq.JSONB,
8183
jsonSchema: {
8284
schema: {

app/models/reports/seqqc.js

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
const {DEFAULT_COLUMNS, DEFAULT_REPORT_OPTIONS} = require('../base');
2+
3+
module.exports = (sequelize, Sq) => {
4+
const seqQC = sequelize.define('seqQC', {
5+
...DEFAULT_COLUMNS,
6+
reportId: {
7+
name: 'reportId',
8+
field: 'report_id',
9+
type: Sq.INTEGER,
10+
references: {
11+
model: 'reports',
12+
key: 'id',
13+
},
14+
},
15+
reads: {
16+
name: 'Reads',
17+
field: 'reads',
18+
type: Sq.TEXT,
19+
},
20+
bioQC: {
21+
name: 'bioQC',
22+
field: 'bio_qc',
23+
type: Sq.TEXT,
24+
},
25+
labQC: {
26+
name: 'labQC',
27+
field: 'lab_qc',
28+
type: Sq.TEXT,
29+
},
30+
sample: {
31+
name: 'Sample',
32+
field: 'sample',
33+
type: Sq.TEXT,
34+
},
35+
library: {
36+
name: 'Library',
37+
field: 'library',
38+
type: Sq.TEXT,
39+
},
40+
coverage: {
41+
name: 'Coverage',
42+
field: 'coverage',
43+
type: Sq.TEXT,
44+
},
45+
inputNg: {
46+
name: 'InputNg',
47+
field: 'input_ng',
48+
type: Sq.TEXT,
49+
},
50+
inputUg: {
51+
name: 'InputUg',
52+
field: 'input_ug',
53+
type: Sq.TEXT,
54+
},
55+
protocol: {
56+
name: 'Protocol',
57+
field: 'protocol',
58+
type: Sq.TEXT,
59+
},
60+
sampleName: {
61+
name: 'SampleName',
62+
field: 'sample_name',
63+
type: Sq.TEXT,
64+
},
65+
duplicateReadsPerc: {
66+
name: 'DuplicateReadsPerc',
67+
field: 'duplicate_reads_perc',
68+
type: Sq.TEXT,
69+
},
70+
}, {
71+
...DEFAULT_REPORT_OPTIONS,
72+
tableName: 'reports_seqqc',
73+
scopes: {
74+
public: {
75+
attributes: {exclude: ['id', 'reportId', 'deletedAt', 'updatedBy']},
76+
},
77+
},
78+
});
79+
80+
// set instance methods
81+
seqQC.prototype.view = function (scope) {
82+
if (scope === 'public') {
83+
const {
84+
id, reportId, deletedAt, updatedBy, ...publicView
85+
} = this.dataValues;
86+
return publicView;
87+
}
88+
return this;
89+
};
90+
91+
return seqQC;
92+
};

app/routes/report/appendices.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ router.route('/')
1313
try {
1414
const result = await db.models.report.findOne({
1515
where: {ident: req.report.ident},
16-
attributes: ['seqQC', 'config'],
16+
attributes: ['seqQc', 'config'],
17+
include: ['seqQC'],
1718
});
1819
return res.json(result);
1920
} catch (error) {
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
const TABLE = 'reports_seqqc';
2+
const {DEFAULT_COLUMNS} = require('../../app/models/base');
3+
4+
module.exports = {
5+
up: (queryInterface, Sq) => {
6+
// Create new notifications tables
7+
return queryInterface.sequelize.transaction(async (transaction) => {
8+
await queryInterface.renameColumn('reports', 'seqQC', 'seq_qc', {transaction});
9+
await queryInterface.createTable(TABLE, {
10+
...DEFAULT_COLUMNS,
11+
reportId: {
12+
name: 'reportId',
13+
field: 'report_id',
14+
type: Sq.INTEGER,
15+
references: {
16+
model: 'reports',
17+
key: 'id',
18+
},
19+
onDelete: 'CASCADE',
20+
onUpdate: 'CASCADE',
21+
allowNull: false,
22+
},
23+
reads: {
24+
name: 'Reads',
25+
field: 'reads',
26+
type: Sq.TEXT,
27+
},
28+
bioQC: {
29+
name: 'bioQC',
30+
field: 'bio_qc',
31+
type: Sq.TEXT,
32+
},
33+
labQC: {
34+
name: 'labQC',
35+
field: 'lab_qc',
36+
type: Sq.TEXT,
37+
},
38+
sample: {
39+
name: 'Sample',
40+
field: 'sample',
41+
type: Sq.TEXT,
42+
},
43+
library: {
44+
name: 'Library',
45+
field: 'library',
46+
type: Sq.TEXT,
47+
},
48+
coverage: {
49+
name: 'Coverage',
50+
field: 'coverage',
51+
type: Sq.TEXT,
52+
},
53+
inputNg: {
54+
name: 'InputNg',
55+
field: 'input_ng',
56+
type: Sq.TEXT,
57+
},
58+
inputUg: {
59+
name: 'InputUg',
60+
field: 'input_ug',
61+
type: Sq.TEXT,
62+
},
63+
protocol: {
64+
name: 'Protocol',
65+
field: 'protocol',
66+
type: Sq.TEXT,
67+
},
68+
sampleName: {
69+
name: 'SampleName',
70+
field: 'sample_name',
71+
type: Sq.TEXT,
72+
},
73+
duplicateReadsPerc: {
74+
name: 'DuplicateReadsPerc',
75+
field: 'duplicate_reads_perc',
76+
type: Sq.TEXT,
77+
},
78+
}, {transaction});
79+
});
80+
},
81+
82+
down: () => {
83+
throw new Error('Not Implemented!');
84+
},
85+
};

migrations/latest/20260204195816-DEVSU-2787-add-data-type-column.js renamed to migrations/v8.4.0/20260204195816-DEVSU-2787-add-data-type-column.js

File renamed without changes.

0 commit comments

Comments
 (0)