-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[O2B-1118] Add migration files and models for quality control flag ty…
…pes (#1380) * expose api * add test * add tests * amend * docs * amend test * amend * add Data Passes page * expose page * styling * add reset method * rename * use sorting * add unit * docs * add filtering by data pass id * add test * amend test * amend test * init * use name instead of id * amend test * rename * use name instead of id * put instance * add to view and model * page openable * amend profiles * show qualities * refactor * cleanup * rename * rename * use filtering by name * add test * use generic model * aboid undefined destruciton error * use proper method * amend cell expected content * use in RunsOverviewModel * rename * rename * touched getAllRuns * extend pai * add styling and css * rename * amend test * cleanup * linter * make uppercase * amend test * add test * use correct page * amend dtest * amend test * amend tst * cleanup * amend * use id * use builder * refactor, add spinner * reset exportableItems * corrent condition * refactor * cleanup * replace build href * cleanup * correct filter values: * fixes * cleanup * make detectors fetching prvate * refactor * rename * rename * change error store * refactor * wip * cleanup * amend view * cleanup * unify title styling * unify title styling in RunsPerLhcPeriod * rename * docs correct * refactor * docs * amend test * fix * modify cell value checking * modify width * add badge * adds migration file * models WIP * add associations * amend tests * add provenance * rename fk * add associations names * simplify * fix association * amend test * docs * add typedef * :typedefs * typdefs * fix * fix * rename * change name * rename * rename * rename * amend association * fix naming * rename * amend naming * a * amend associations * disallow null * merge main * add addociation name * miss * fixed * revoke * rm verifications * name archived * obsolate to archived * simplify association * a * Revert "a" This reverts commit a7b880c. * Revert "simplify association" This reverts commit ad453da. * docs * rename * simplify * refactor * refactor * refactor * a * add assoc * rename * cleanup * fix associations * comment * rename table * reason to type * rename * rename * rename * fix * typo * typo * rename * add modification control * update modification control * update associatioin name * add color * add assoc name * add seeder * cherry-pick * cleanup * cleanup * use QC * restore * fix * use QC * add timeout * validator * validator * varchar length
- Loading branch information
Showing
5 changed files
with
239 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
lib/database/migrations/20240226102034-create-quality-control-flags-tables.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
'use strict'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
up: async (queryInterface, Sequelize) => queryInterface.sequelize.transaction(async (transaction) => { | ||
await queryInterface.createTable('quality_control_flag_types', { | ||
// Properties | ||
id: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
name: { | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
unique: true, | ||
}, | ||
method: { | ||
type: Sequelize.STRING, | ||
unique: true, | ||
allowNull: false, | ||
}, | ||
bad: { | ||
type: Sequelize.BOOLEAN, | ||
allowNull: false, | ||
}, | ||
color: { | ||
type: Sequelize.STRING(7), | ||
allowNull: true, | ||
}, | ||
|
||
archived_at: { | ||
type: Sequelize.DATE, | ||
allowNull: true, | ||
}, | ||
|
||
last_updated_by_id: { | ||
type: Sequelize.INTEGER, | ||
allowNull: true, | ||
references: { | ||
model: 'users', | ||
key: 'id', | ||
}, | ||
}, | ||
|
||
created_by_id: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: 'users', | ||
key: 'id', | ||
}, | ||
}, | ||
|
||
// Timestamps | ||
created_at: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'), | ||
}, | ||
updated_at: { | ||
allowNull: false, | ||
type: Sequelize.DATE, | ||
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), | ||
}, | ||
}, { transaction }); | ||
}), | ||
|
||
down: async (queryInterface) => queryInterface.sequelize.transaction(async (transaction) => { | ||
await queryInterface.dropTable('quality_control_flag_types', { transaction }); | ||
}), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* @license | ||
* Copyright CERN and copyright holders of ALICE O2. This software is | ||
* distributed under the terms of the GNU General Public License v3 (GPL | ||
* Version 3), copied verbatim in the file "COPYING". | ||
* | ||
* See http://alice-o2.web.cern.ch/license for full licensing information. | ||
* | ||
* In applying this license CERN does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an Intergovernmental Organization | ||
* or submit itself to any jurisdiction. | ||
*/ | ||
|
||
const Sequelize = require('sequelize'); | ||
|
||
module.exports = (sequelize) => { | ||
const QCFlagType = sequelize.define( | ||
'QCFlagType', | ||
{ | ||
id: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
name: { | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
unique: true, | ||
}, | ||
method: { | ||
type: Sequelize.STRING, | ||
unique: true, | ||
allowNull: false, | ||
}, | ||
bad: { | ||
type: Sequelize.BOOLEAN, | ||
allowNull: false, | ||
}, | ||
color: { | ||
type: Sequelize.STRING(7), | ||
allowNull: true, | ||
validate: { | ||
is: /^#[0-9a-fA-F]{6}$/i, | ||
}, | ||
}, | ||
archivedAt: { | ||
type: Sequelize.DATE, | ||
allowNull: true, | ||
}, | ||
archived: { | ||
type: Sequelize.VIRTUAL, | ||
defaultValue: null, | ||
// eslint-disable-next-line require-jsdoc | ||
get() { | ||
return Boolean(this.getDataValue('archivedAt')); | ||
}, | ||
}, | ||
}, | ||
{ tableName: 'quality_control_flag_types' }, | ||
); | ||
|
||
QCFlagType.associate = (models) => { | ||
QCFlagType.belongsTo(models.User, { as: 'createdBy', foreignKey: 'createdById' }); | ||
QCFlagType.belongsTo(models.User, { as: 'lastUpdatedBy', foreignKey: 'lastUpdatedById' }); | ||
}; | ||
|
||
return QCFlagType; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* @license | ||
* Copyright CERN and copyright holders of ALICE O2. This software is | ||
* distributed under the terms of the GNU General Public License v3 (GPL | ||
* Version 3), copied verbatim in the file "COPYING". | ||
* | ||
* See http://alice-o2.web.cern.ch/license for full licensing information. | ||
* | ||
* In applying this license CERN does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an Intergovernmental Organization | ||
* or submit itself to any jurisdiction. | ||
*/ | ||
|
||
/** | ||
* @typedef SequelizeQCFlagType | ||
* | ||
* @property {number} id | ||
* @property {string} name | ||
* @property {string} method | ||
* @property {boolean} bad | ||
* @property {string} color as hex | ||
* | ||
* @property {boolean} archived | ||
* @property {Date} archivedAt | ||
* | ||
* @property {Date} createdAt | ||
* @property {number} createdById | ||
* @property {SequelizeUser} createdBy | ||
* @property {Date} updatedAt | ||
* @property {number} lastUpdatedById | ||
* @property {SequelizeUser} lastUpdatedBy | ||
*/ |
63 changes: 63 additions & 0 deletions
63
lib/database/seeders/20240213120811-quality-control-flags.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* @license | ||
* Copyright CERN and copyright holders of ALICE O2. This software is | ||
* distributed under the terms of the GNU General Public License v3 (GPL | ||
* Version 3), copied verbatim in the file "COPYING". | ||
* | ||
* See http://alice-o2.web.cern.ch/license for full licensing information. | ||
* | ||
* In applying this license CERN does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an Intergovernmental Organization | ||
* or submit itself to any jurisdiction. | ||
*/ | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
up: async (queryInterface) => | ||
queryInterface.sequelize.transaction((transaction) => | ||
Promise.all([ | ||
queryInterface.bulkInsert('quality_control_flag_types', [ | ||
{ | ||
id: 2, | ||
name: 'UnknownQuality', | ||
method: 'Unknown Quality', | ||
bad: true, | ||
created_by_id: 1, | ||
}, | ||
{ | ||
id: 3, | ||
name: 'CertifiedByExpert', | ||
method: 'Certified by Expert', | ||
bad: false, | ||
created_by_id: 1, | ||
}, | ||
{ | ||
id: 11, | ||
name: 'LimitedAcceptance', | ||
method: 'Limited acceptance', | ||
bad: true, | ||
color: '#FFFF00', | ||
created_by_id: 1, | ||
}, | ||
{ | ||
id: 12, | ||
name: 'BadPID', | ||
method: 'Bad PID', | ||
bad: true, | ||
created_by_id: 1, | ||
}, | ||
{ | ||
id: 13, | ||
name: 'Bad', | ||
method: 'Bad', | ||
bad: true, | ||
created_by_id: 1, | ||
}, | ||
|
||
], { transaction }), | ||
])), | ||
|
||
down: async (queryInterface) => | ||
queryInterface.sequelize.transaction((transaction) => | ||
Promise.all([queryInterface.bulkDelete('quality_control_flag_types', null, { transaction })])), | ||
}; |