-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathRunsPerSimulationPassOverviewModel.js
More file actions
133 lines (119 loc) · 4.03 KB
/
Copy pathRunsPerSimulationPassOverviewModel.js
File metadata and controls
133 lines (119 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* @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.
*/
import { buildUrl, RemoteData } from '/js/src/index.js';
import { RunsWithQcModel } from '../Overview/RunsWithQcModel.js';
import { ObservableData } from '../../../utilities/ObservableData.js';
import { getRemoteData } from '../../../utilities/fetch/getRemoteData.js';
import { detectorsProvider } from '../../../services/detectors/detectorsProvider.js';
/**
* Runs Per Simulation Pass overview model
*/
export class RunsPerSimulationPassOverviewModel extends RunsWithQcModel {
/**
* Constructor
* @param {Model} model global model
*/
constructor(model) {
super(model);
this._detectors$ = detectorsProvider.qc$;
this._detectors$.bubbleTo(this);
this.registerDetectorsNotBadFractionFilterModels(this._detectors$);
this._simulationPass$ = new ObservableData(RemoteData.notAsked());
this._simulationPass$.bubbleTo(this);
this._qcSummary$ = new ObservableData(RemoteData.NotAsked());
this._qcSummary$.bubbleTo(this);
}
/**
* Fetch Simulation Pass data which data passes are fetched
* @return {Promise<void>} promise
*/
async _fetchSimulationPass() {
this._simulationPass$.setCurrent(RemoteData.loading());
try {
const { data: simulationPass } = await getRemoteData(`/api/simulationPasses/${this._simulationPassId}`);
this._simulationPass$.setCurrent(RemoteData.success(simulationPass));
} catch (error) {
this._simulationPass$.setCurrent(RemoteData.failure(error));
}
}
/**
* Fetch QC summaries for given simulation pass
* @return {Promise<void>} promise
*/
async _fetchQcSummary() {
this._qcSummary$.setCurrent(RemoteData.loading());
try {
const { data: qcSummary } = await getRemoteData(buildUrl('/api/qcFlags/summary', {
simulationPassId: this._simulationPassId,
mcReproducibleAsNotBad: this._mcReproducibleAsNotBad,
}));
this._qcSummary$.setCurrent(RemoteData.success(qcSummary));
} catch (error) {
this._qcSummary$.setCurrent(RemoteData.failure(error));
}
}
/**
* @inheritdoc
*/
async load() {
this._fetchQcSummary();
this._fetchSimulationPass();
super.load();
}
/**
* @inheritdoc
*/
getRootEndpoint() {
const params = {
filter: {
simulationPassIds: [this._simulationPassId],
},
};
return buildUrl(super.getRootEndpoint(), params);
}
/**
* Set id of current simulation pass which runs are fetched
* @param {number} simulationPassId simulation pass id
*/
set simulationPassId(simulationPassId) {
this._simulationPassId = simulationPassId;
}
/**
* Get id of current simulation pass which runs are fetched
* @return {number} simulationPassId simulation pass id
*/
get simulationPassId() {
return this._simulationPassId;
}
/**
* Get current simulation pass which runs are fetched
* @return {RemoteData<SimulationPass>} simulation pass remote data
*/
get simulationPass() {
return this._simulationPass$.getCurrent();
}
/**
* Get all detectors
* @return {RemoteData<DplDetector[]>} detectors
*/
get detectors() {
return this._detectors$.getCurrent();
}
/**
* QC summary getter
* @return {RemoteData<QcSummary>} QC summary
*/
get qcSummary() {
return this._qcSummary$.getCurrent();
}
}