Skip to content

Commit f099d33

Browse files
committed
[O2B-1533] Move detector ordering into DetectorOrders
Centralise detector ordering maps by moving DEFAULT and RCT switchCase inputs into the ENUM. This consolidates ordering configuration and avoids duplicate definitions in the provider.
1 parent 4e0fa66 commit f099d33

2 files changed

Lines changed: 21 additions & 24 deletions

File tree

lib/public/domain/enums/DetectorOrders.js

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

14+
import { DetectorType } from './DetectorTypes.js';
15+
1416
export const DetectorOrders = Object.freeze({
15-
DEFAULT: 'DEFAULT',
16-
RCT: 'RCT',
17+
DEFAULT: {
18+
[DetectorType.OTHER]: 0,
19+
[DetectorType.VIRTUAL]: 1,
20+
[DetectorType.PHYSICAL]: 2,
21+
[DetectorType.AOT_GLO]: 3,
22+
[DetectorType.AOT_EVENT]: 4,
23+
[DetectorType.MUON_GLO]: 5,
24+
[DetectorType.QC_ONLY]: 6,
25+
},
26+
RCT: {
27+
[DetectorType.OTHER]: 0,
28+
[DetectorType.AOT_GLO]: 1,
29+
[DetectorType.AOT_EVENT]: 2,
30+
[DetectorType.MUON_GLO]: 3,
31+
[DetectorType.VIRTUAL]: 4,
32+
[DetectorType.PHYSICAL]: 5,
33+
[DetectorType.QC_ONLY]: 6,
34+
},
1735
});

lib/public/services/detectors/detectorsProvider.js

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,6 @@ const getPhysicalDetectorsFromAllDetectors = (allDetectors) => allDetectors.filt
3939
const getQcDetectorsFromAllDetectors = (allDetectors) => allDetectors
4040
.filter(({ type, name }) => QC_DETECTORS.includes(type) && !DETECTORS_EXCLUDED_FROM_QC.includes(name));
4141

42-
const ORDERING_KEYS = {
43-
[DetectorOrders.DEFAULT]: {
44-
[DetectorType.OTHER]: 0,
45-
[DetectorType.VIRTUAL]: 1,
46-
[DetectorType.PHYSICAL]: 2,
47-
[DetectorType.AOT_GLO]: 3,
48-
[DetectorType.AOT_EVENT]: 4,
49-
[DetectorType.MUON_GLO]: 5,
50-
[DetectorType.QC_ONLY]: 6,
51-
},
52-
[DetectorOrders.RCT]: {
53-
[DetectorType.OTHER]: 0,
54-
[DetectorType.AOT_GLO]: 1,
55-
[DetectorType.AOT_EVENT]: 2,
56-
[DetectorType.MUON_GLO]: 3,
57-
[DetectorType.VIRTUAL]: 4,
58-
[DetectorType.PHYSICAL]: 5,
59-
[DetectorType.QC_ONLY]: 6,
60-
},
61-
};
62-
6342
/**
6443
* Service class to fetch detectors from the backend
6544
*/
@@ -99,7 +78,7 @@ export class DetectorsProvider extends RemoteDataProvider {
9978
*/
10079
async getRemoteData() {
10180
const { data: detectors } = await getRemoteData('/api/detectors');
102-
const typeToOrderingKey = (type) => switchCase(type, ORDERING_KEYS[this._detectorOrder]);
81+
const typeToOrderingKey = (type) => switchCase(type, this._detectorOrder);
10382

10483
const orderingKey = (detector1, detector2) => {
10584
const specialPair = ['ZDC', 'TST'];

0 commit comments

Comments
 (0)