Skip to content

Commit

Permalink
[O2B-1118] Add migration files and models for quality control flag ty…
Browse files Browse the repository at this point in the history
…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
xsalonx authored Mar 12, 2024
1 parent ed80ae8 commit 04383e6
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 0 deletions.
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 });
}),
};
2 changes: 2 additions & 0 deletions lib/database/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const User = require('./user');
const LhcPeriod = require('./lhcPeriod');
const LhcPeriodStatistics = require('./lhcPeriodsStatistics');
const DataPass = require('./dataPass.js');
const QCFlagType = require('./qcFlagType.js');
const SimulationPass = require('./simulationPass.js');

module.exports = (sequelize) => {
Expand Down Expand Up @@ -67,6 +68,7 @@ module.exports = (sequelize) => {
LhcPeriod: LhcPeriod(sequelize),
LhcPeriodStatistics: LhcPeriodStatistics(sequelize),
DataPass: DataPass(sequelize),
QCFlagType: QCFlagType(sequelize),
SimulationPass: SimulationPass(sequelize),
};

Expand Down
69 changes: 69 additions & 0 deletions lib/database/models/qcFlagType.js
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;
};
32 changes: 32 additions & 0 deletions lib/database/models/typedefs/SequelizeQCFlagType.js
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 lib/database/seeders/20240213120811-quality-control-flags.js
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 })])),
};

0 comments on commit 04383e6

Please sign in to comment.