Skip to content

Commit 812d358

Browse files
committed
add
1 parent 19367e5 commit 812d358

2 files changed

Lines changed: 54 additions & 3 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
'use strict';
15+
16+
const { Op } = require('sequelize');
17+
const { DetectorType } = require('../../../domain/enums/DetectorTypes.js');
18+
19+
const NEW_QC_DETECTORS = [
20+
'VTX',
21+
'MTE',
22+
'AOT-GLO',
23+
'EVS',
24+
'CEN',
25+
'EVP',
26+
'AOT-Event',
27+
'MUD',
28+
'GMU',
29+
'MUON-GLO',
30+
];
31+
32+
/** @type {import('sequelize-cli').Migration} */
33+
module.exports = {
34+
up: async (queryInterface) => queryInterface.sequelize.transaction(async () => {
35+
await queryInterface.bulkInsert('detectors', NEW_QC_DETECTORS.map((name) => ({ name, type: DetectorType.QC_ONLY })));
36+
}),
37+
38+
down: async (queryInterface) => queryInterface.sequelize.transaction(async () => {
39+
await queryInterface.bulkDelete('detectors', { name: { [Op.in]: NEW_QC_DETECTORS } });
40+
}),
41+
};

lib/public/services/detectors/detectorsProvider.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* or submit itself to any jurisdiction.
1212
*/
1313

14+
import { switchCase } from '/js/src/index.js';
1415
import { getRemoteData } from '../../utilities/fetch/getRemoteData.js';
1516
import { ObservableData } from '../../utilities/ObservableData.js';
1617
import { DetectorType, DATA_TAKING_DETECTOR_TYPES } from '../../domain/enums/DetectorTypes.js';
@@ -32,10 +33,10 @@ const getPhysicalDetectorsFromAllDetectors = (allDetectors) => allDetectors.filt
3233
* Return the QC detectors from a list of detectors
3334
*
3435
* @param {Detector[]} allDetectors the list of all detectors
35-
* @return {Detector[]} physical detectors
36+
* @return {Detector[]} QC detectors
3637
*/
3738
const getQcDetectorsFromAllDetectors = (allDetectors) => allDetectors
38-
.filter(({ type, name }) => [DetectorType.PHYSICAL, DetectorType.QC].includes(type) && !DETECTORS_EXCLUDED_FROM_QC.includes(name));
39+
.filter(({ type, name }) => [DetectorType.PHYSICAL, DetectorType.QC_ONLY].includes(type) && !DETECTORS_EXCLUDED_FROM_QC.includes(name));
3940

4041
/**
4142
* Service class to fetch detectors from the backend
@@ -73,7 +74,14 @@ export class DetectorsProvider extends RemoteDataProvider {
7374
*/
7475
async getRemoteData() {
7576
const { data } = await getRemoteData('/api/detectors');
76-
data.sort(({ name: name1 }, { name: name2 }) => name1.localeCompare(name2));
77+
const typeToOrderingKey = (type) => switchCase(type, {
78+
[DetectorType.OTHER]: 0,
79+
[DetectorType.VIRTUAL]: 1,
80+
[DetectorType.PHYSICAL]: 2,
81+
[DetectorType.QC_ONLY]: 3,
82+
});
83+
data.sort(({ name: name1, type: type1 }, { name: name2, type: type2 }) =>
84+
-(typeToOrderingKey(type1) - typeToOrderingKey(type2)) * 10 + name1.localeCompare(name2));
7785
return data;
7886
}
7987

@@ -142,3 +150,5 @@ export class DetectorsProvider extends RemoteDataProvider {
142150
}
143151

144152
export const detectorsProvider = new DetectorsProvider();
153+
154+
window.d = detectorsProvider;

0 commit comments

Comments
 (0)