Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
xsalonx committed Mar 4, 2024
2 parents ab9815b + 61a2a2d commit d209921
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/database/models/qualityControlFlagType.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = (sequelize) => {
);

QualityControlFlagType.associate = (models) => {
QualityControlFlagType.hasMany(models.QualityControlFlag, { foreignKey: 'flagTypeId' });
QualityControlFlagType.hasMany(models.QualityControlFlag, { as: 'flags', foreignKey: 'flagTypeId' });
QualityControlFlagType.belongsTo(models.User, { as: 'createdBy', foreignKey: 'createdById' });
QualityControlFlagType.belongsTo(models.User, { as: 'lastUpdatedBy', foreignKey: 'lastUpdatedById' });
};
Expand Down
109 changes: 108 additions & 1 deletion lib/database/seeders/20240213120811-quality-control-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,116 @@ module.exports = {
},

], { transaction }),

queryInterface.bulkInsert('quality_control_flags', [

/** Flags for runNumber: 106, LHC22b_apass1, CPV */
{ // Run trg time middle point: 1565314200, radius: 45000 seconds
id: 1,
from: new Date((1565314200 - 10000) * 1000),
to: new Date((1565314200 + 10000) * 1000),
comment: 'Some qc comment 1',

// Associations
created_by_id: 1,
flag_type_id: 11, // LimitedAcceptance
run_number: 106,
dpl_detector_id: 1, // CPV
created_at: new Date(1707825436000),
},

{ // Run trg time middle point: 1565314200, radius: 45000 seconds
id: 2,
from: new Date((1565314200 + 15000) * 1000),
to: new Date((1565314200 + 20000) * 1000),
comment: 'Some qc comment 2',

// Associations
created_by_id: 1,
flag_type_id: 11, // LimitedAcceptance
run_number: 106,
dpl_detector_id: 1, // CPV
created_at: new Date(1707825436000),
},

{ // Run trg time middle point: 1565314200, radius: 45000 seconds
id: 3,
from: new Date((1565314200 + 25000) * 1000),
to: new Date((1565314200 + 30000) * 1000),
comment: 'Some qc comment 3',

// Associations
created_by_id: 1,
flag_type_id: 13, // Bad
run_number: 106,
dpl_detector_id: 1, // CPV
created_at: new Date(1707825436000),
},

/** Flags for runNumber: 1, LHC22b_apass2, CPV */
{ // Run trg time middle point: 1647914400, radius: 46800 seconds
id: 4,
from: new Date((1647914400 + 10000) * 1000),
to: new Date((1647914400 + 10000) * 1000),
comment: 'Some qc comment 4',

// Associations
created_by_id: 2,
flag_type_id: 13, // Bad
run_number: 1,
dpl_detector_id: 1, // CPV
created_at: new Date(1707825436000),
},

{ // Run trg time middle point: 1565307000, radius: 45000 seconds
id: 5,
from: new Date((1565307000 - 35000) * 1000),
to: new Date((1565307000 + 30000) * 1000),
comment: 'Some qc comment 4',

// Associations
created_by_id: 2,
flag_type_id: 13, // Bad
run_number: 106,
dpl_detector_id: 1, // CPV
created_at: new Date(1707825436000),
},
], { transaction }),

queryInterface.bulkInsert('data_pass_quality_control_flag', [
{
data_pass_id: 1, // LHC22b_apass1
quality_control_flag_id: 1,
},
{
data_pass_id: 1, // LHC22b_apass1
quality_control_flag_id: 2,
},
{
data_pass_id: 1, // LHC22b_apass1
quality_control_flag_id: 3,
},

{
data_pass_id: 2, // LHC22b_apass2
quality_control_flag_id: 4,
},
], { transaction }),

queryInterface.bulkInsert('simulation_pass_quality_control_flag', [
{
simulation_pass_id: 1, // LHC23k6c
quality_control_flag_id: 5,
},
], { transaction }),
])),

down: async (queryInterface) =>
queryInterface.sequelize.transaction((transaction) =>
Promise.all([queryInterface.bulkDelete('quality_control_flag_types', null, { transaction })])),
Promise.all([
queryInterface.bulkDelete('data_pass_quality_control_flag', null, { transaction }),
queryInterface.bulkDelete('simulation_pass_quality_control_flag', null, { transaction }),
queryInterface.bulkDelete('quality_control_flags', null, { transaction }),
queryInterface.bulkDelete('quality_control_flag_types', null, { transaction }),
])),
};

0 comments on commit d209921

Please sign in to comment.