From 8ca01ff38cb4cfc47b321fc36b0ab16f7cbf6968 Mon Sep 17 00:00:00 2001 From: Martin Boulais <31805063+martinboulais@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:30:44 +0100 Subject: [PATCH 1/2] [O2B-1406] Add n TF orbits --- lib/database/adapters/RunAdapter.js | 3 +++ .../20241218095948-add-n-tf-orbits.js | 17 +++++++++++++++++ lib/database/models/run.js | 4 ++++ lib/database/models/typedefs/SequelizeRun.js | 1 + lib/database/seeders/20200713103855-runs.js | 1 + lib/domain/dtos/UpdateRunByRunNumberDto.js | 1 + lib/domain/entities/Run.js | 1 + test/api/runs.test.js | 2 ++ test/lib/usecases/run/UpdateRunUseCase.test.js | 2 ++ 9 files changed, 32 insertions(+) create mode 100644 lib/database/migrations/20241218095948-add-n-tf-orbits.js diff --git a/lib/database/adapters/RunAdapter.js b/lib/database/adapters/RunAdapter.js index cbddb9d3d8..289ba0dab7 100644 --- a/lib/database/adapters/RunAdapter.js +++ b/lib/database/adapters/RunAdapter.js @@ -140,6 +140,7 @@ class RunAdapter { tfFileSize, otherFileCount, otherFileSize, + nTfOrbits, lhcFill, flpRoles, logs, @@ -214,6 +215,7 @@ class RunAdapter { tfFileSize: tfFileSize !== null ? String(tfFileSize) : null, otherFileCount, otherFileSize: otherFileSize !== null ? String(otherFileSize) : null, + nTfOrbits: nTfOrbits !== null ? String(nTfOrbits) : null, lhcFill, crossSection, triggerEfficiency, @@ -322,6 +324,7 @@ class RunAdapter { tfFileSize: entityObject.tfFileSize, otherFileCount: entityObject.otherFileCount, otherFileSize: entityObject.otherFileSize, + nTfOrbits: entityObject.nTfOrbits, concatenatedDetectors: entityObject.detectors, definition: entityObject.definition, calibrationStatus: entityObject.calibrationStatus, diff --git a/lib/database/migrations/20241218095948-add-n-tf-orbits.js b/lib/database/migrations/20241218095948-add-n-tf-orbits.js new file mode 100644 index 0000000000..992ad12b68 --- /dev/null +++ b/lib/database/migrations/20241218095948-add-n-tf-orbits.js @@ -0,0 +1,17 @@ +'use strict'; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + up: async (queryInterface, Sequelize) => await queryInterface.addColumn( + 'runs', + 'n_tf_orbits', + { + type: Sequelize.DataTypes.BIGINT, + allowNull: true, + default: null, + after: 'other_file_size', + }, + ), + + down: async (queryInterface) => await queryInterface.removeColumn('runs', 'n_tf_orbits'), +}; diff --git a/lib/database/models/run.js b/lib/database/models/run.js index ab258b7dbb..0f11a2aca5 100644 --- a/lib/database/models/run.js +++ b/lib/database/models/run.js @@ -203,6 +203,10 @@ module.exports = (sequelize) => { type: Sequelize.BIGINT, default: null, }, + nTfOrbits: { + type: Sequelize.BIGINT, + default: null, + }, definition: { type: Sequelize.ENUM(...RUN_DEFINITIONS), }, diff --git a/lib/database/models/typedefs/SequelizeRun.js b/lib/database/models/typedefs/SequelizeRun.js index d8633b6d15..ad299110f3 100644 --- a/lib/database/models/typedefs/SequelizeRun.js +++ b/lib/database/models/typedefs/SequelizeRun.js @@ -67,6 +67,7 @@ * @property {string|number|null} tfFileSize * @property {string|null} otherFileCount * @property {string|number|null} otherFileSize + * @property {string|number|null} nTfOrbits * @property {number|null} inelasticInteractionRateAvg * @property {number|null} inelasticInteractionRateAtStart * @property {number|null} inelasticInteractionRateAtMid diff --git a/lib/database/seeders/20200713103855-runs.js b/lib/database/seeders/20200713103855-runs.js index 1eeda8e0a8..7f28469612 100644 --- a/lib/database/seeders/20200713103855-runs.js +++ b/lib/database/seeders/20200713103855-runs.js @@ -53,6 +53,7 @@ module.exports = { tf_file_size: '214920239535280', other_file_count: 50, other_file_size: '9999999999999999', + n_tf_orbits: '9999999999999999', definition: RunDefinition.PHYSICS, cross_section: 1.23, trigger_efficiency: 2.34, diff --git a/lib/domain/dtos/UpdateRunByRunNumberDto.js b/lib/domain/dtos/UpdateRunByRunNumberDto.js index fe1426d6a3..1440c49943 100644 --- a/lib/domain/dtos/UpdateRunByRunNumberDto.js +++ b/lib/domain/dtos/UpdateRunByRunNumberDto.js @@ -37,6 +37,7 @@ const BodyDto = Joi.object({ tfFileSize: Joi.string().optional(), otherFileCount: Joi.number().optional(), otherFileSize: Joi.string().optional(), + nTfOrbits: Joi.string().optional(), crossSection: Joi.number().optional(), triggerEfficiency: Joi.number().optional(), triggerAcceptance: Joi.number().optional(), diff --git a/lib/domain/entities/Run.js b/lib/domain/entities/Run.js index 7f7bcab11c..4083389bbc 100644 --- a/lib/domain/entities/Run.js +++ b/lib/domain/entities/Run.js @@ -65,6 +65,7 @@ * @property {string|null} tfFileSize * @property {string|null} otherFileCount * @property {string|null} otherFileSize + * @property {string|null} nTfOrbits * @property {number|null} muInelasticInteractionRate * @property {number|null} inelasticInteractionRateAvg * @property {number|null} inelasticInteractionRateAtStart diff --git a/test/api/runs.test.js b/test/api/runs.test.js index 8b1ccbc36e..53e8868d11 100644 --- a/test/api/runs.test.js +++ b/test/api/runs.test.js @@ -1203,6 +1203,7 @@ module.exports = () => { tfFileSize: BIG_INT_NUMBER, otherFileCount: 123156132, otherFileSize: BIG_INT_NUMBER, + nTfOrbits: BIG_INT_NUMBER, crossSection: 0.1, triggerEfficiency: 0.2, triggerAcceptance: 0.3, @@ -1235,6 +1236,7 @@ module.exports = () => { expect(data.tfFileSize).to.equal(BIG_INT_NUMBER); expect(data.otherFileCount).to.equal(123156132); expect(data.otherFileSize).to.equal(BIG_INT_NUMBER); + expect(data.nTfOrbits).to.equal(BIG_INT_NUMBER); expect(data.triggerEfficiency).to.equal(0.2); expect(data.triggerAcceptance).to.equal(0.3); expect(data.phaseShiftAtStartBeam1).to.equal(0.4); diff --git a/test/lib/usecases/run/UpdateRunUseCase.test.js b/test/lib/usecases/run/UpdateRunUseCase.test.js index 913aabb14c..838283a46e 100644 --- a/test/lib/usecases/run/UpdateRunUseCase.test.js +++ b/test/lib/usecases/run/UpdateRunUseCase.test.js @@ -58,6 +58,7 @@ module.exports = () => { tfFileSize: BIG_INT_NUMBER, otherFileCount: 123156132, otherFileSize: BIG_INT_NUMBER, + nTfOrbits: BIG_INT_NUMBER, crossSection: 0.1, triggerEfficiency: 0.2, triggerAcceptance: 0.3, @@ -324,6 +325,7 @@ module.exports = () => { expect(result.tfFileSize).to.equal(BIG_INT_NUMBER); expect(result.otherFileCount).to.equal(123156132); expect(result.otherFileSize).to.equal(BIG_INT_NUMBER); + expect(result.nTfOrbits).to.equal(BIG_INT_NUMBER); expect(result.crossSection).to.equal(0.1); expect(result.triggerEfficiency).to.equal(0.2); expect(result.triggerAcceptance).to.equal(0.3); From 202a9067bca559c2c718d164f5cdfa3fca2e6ba6 Mon Sep 17 00:00:00 2001 From: Martin Boulais <31805063+martinboulais@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:44:03 +0100 Subject: [PATCH 2/2] Add display --- lib/public/views/Runs/Details/runDetailsComponent.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/public/views/Runs/Details/runDetailsComponent.js b/lib/public/views/Runs/Details/runDetailsComponent.js index 81d1e5d95c..02118fe0f5 100644 --- a/lib/public/views/Runs/Details/runDetailsComponent.js +++ b/lib/public/views/Runs/Details/runDetailsComponent.js @@ -277,6 +277,10 @@ export const runDetailsComponent = (runDetailsModel, router) => runDetailsModel. h('strong', 'TF Files size'), formatFileSize(run.tfFileSize), ]), + h('.flex-column.items-center.flex-grow', [ + h('strong', 'TF Orbits count'), + formatItemsCount(run.nTfOrbits), + ]), h('strong', '|'), h('.flex-column.items-center.flex-grow', [ h('strong', 'Other Files count'),