Skip to content

Commit f1c5456

Browse files
committed
Merge branch 'main' of github.com:AliceO2Group/Bookkeeping into improv/O2B-1570/split-sql-requests-with-sequalize
2 parents e38577e + 6ff81d8 commit f1c5456

5 files changed

Lines changed: 70 additions & 44 deletions

File tree

lib/public/views/Runs/Overview/RunsWithQcModel.js

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -140,36 +140,49 @@ export class RunsWithQcModel extends RunsOverviewModel {
140140
}
141141

142142
/**
143-
* Register not-bad fraction detectors filtering model
143+
* Register not-bad fraction detectors filtering model and update it when detectors are loaded
144+
* Also, trigger an immediate update if detectors are already loaded at the moment of registration
144145
*
145146
* @param {ObservableData<RemoteData<Detector>>} detectors$ detectors remote data observable
146147
*/
147148
registerDetectorsNotBadFractionFilterModels(detectors$) {
148-
detectors$.observe((observableData) => observableData.getCurrent().apply({
149-
Success: (detectors) => detectors.forEach(({ id }) => {
150-
this._filteringModel.put(`detectorsQc[_${id}][notBadFraction]`, new NumericalComparisonFilterModel({
151-
scale: 0.01,
152-
integer: false,
153-
}));
154-
}),
155-
}));
149+
const callback = (observableData) => {
150+
const current = observableData.getCurrent();
151+
current?.apply({
152+
Success: (detectors) => detectors.forEach(({ id }) => {
153+
this._filteringModel.put(`detectorsQc[_${id}][notBadFraction]`, new NumericalComparisonFilterModel({
154+
scale: 0.01,
155+
integer: false,
156+
}));
157+
}),
158+
});
159+
};
160+
detectors$.observe(callback);
161+
callback(detectors$);
156162
}
157163

158164
/**
159-
* Register detectors for QC flags data export
165+
* Register detectors for QC flags data export and update export configuration when detectors are loaded
166+
* Also, trigger an immediate update if detectors are already loaded at the moment of registration
160167
*
161168
* @param {ObservableData<RemoteData<Detector>>} detectors$ detectors remote data observable
162169
*/
163170
registerDetectorsForQcFlagsDataExport(detectors$) {
164-
detectors$.observe((observableData) => observableData.getCurrent().apply({
165-
Success: (detectors) => {
166-
this._exportModel.setDataExportConfiguration({
167-
...baseDataExportConfiguration,
168-
...qcFlagsExportConfigurationFactory(detectors),
169-
});
170-
},
171-
Other: () => null,
172-
}));
171+
const callback = (observableData) => {
172+
const current = observableData.getCurrent();
173+
current?.apply({
174+
Success: (detectors) => {
175+
this._exportModel.setDataExportConfiguration({
176+
...baseDataExportConfiguration,
177+
...qcFlagsExportConfigurationFactory(detectors),
178+
});
179+
},
180+
Other: () => null,
181+
});
182+
};
183+
detectors$.observe(callback);
184+
// Also trigger immediately if detectors are already loaded
185+
callback(detectors$);
173186
}
174187

175188
/**
@@ -179,9 +192,13 @@ export class RunsWithQcModel extends RunsOverviewModel {
179192
*/
180193
registerObservablesQcSummaryDependsOn(detectors$) {
181194
this._observablesQcFlagsSummaryDependsOn$ = detectors$;
182-
183-
this._observablesQcFlagsSummaryDependsOn$
184-
.observe((observableData) => observableData.getCurrent().apply({ Success: () => this._fetchQcSummary() }));
195+
const callback = (observableData) => {
196+
const current = observableData.getCurrent();
197+
current?.apply({ Success: () => this._fetchQcSummary() });
198+
};
199+
this._observablesQcFlagsSummaryDependsOn$.observe(callback);
200+
// Also trigger immediately if detectors are already loaded
201+
callback(this._observablesQcFlagsSummaryDependsOn$);
185202
}
186203

187204
/**
@@ -208,7 +225,7 @@ export class RunsWithQcModel extends RunsOverviewModel {
208225
async _fetchQcSummary() {
209226
const qcSummaryScopeValid = Object.entries(this.qcSummaryScope).filter(([, id]) => id).length == 1;
210227

211-
if (qcSummaryScopeValid && this.detectors && this._observablesQcFlagsSummaryDependsOn$.getCurrent()) {
228+
if (qcSummaryScopeValid && this.detectors && this._observablesQcFlagsSummaryDependsOn$?.getCurrent()) {
212229
mergeRemoteData([this.detectors, this._observablesQcFlagsSummaryDependsOn$.getCurrent()]).match({
213230
Success: async ([detectors]) => {
214231
this._qcSummary$.setCurrent(RemoteData.loading());

lib/public/views/Runs/RunPerDataPass/RunsPerDataPassOverviewModel.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ export class RunsPerDataPassOverviewModel extends FixedPdpBeamTypeRunsOverviewMo
5252
.build();
5353

5454
this._detectors$.bubbleTo(this);
55-
this.registerDetectorsNotBadFractionFilterModels(this._detectors$);
56-
this.registerDetectorsForQcFlagsDataExport(this._detectors$);
57-
this.registerObservablesQcSummaryDependsOn(this._detectors$);
5855

5956
this._markAsSkimmableRequestResult$ = new ObservableData(RemoteData.notAsked());
6057
this._markAsSkimmableRequestResult$.bubbleTo(this);
@@ -135,6 +132,11 @@ export class RunsPerDataPassOverviewModel extends FixedPdpBeamTypeRunsOverviewMo
135132
},
136133
Other: () => null,
137134
}));
135+
136+
this.registerDetectorsNotBadFractionFilterModels(this._detectors$);
137+
this.registerDetectorsForQcFlagsDataExport(this._detectors$);
138+
this.registerObservablesQcSummaryDependsOn(this._detectors$);
139+
138140
super.load();
139141
}
140142

lib/public/views/Runs/RunPerPeriod/RunsPerLhcPeriodOverviewModel.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ export class RunsPerLhcPeriodOverviewModel extends FixedPdpBeamTypeRunsOverviewM
4949
}))
5050
.build();
5151

52-
this.registerDetectorsForQcFlagsDataExport(this._syncDetectors$);
53-
this.registerObservablesQcSummaryDependsOn(this._syncDetectors$);
54-
5552
this._syncDetectors$.bubbleTo(this);
5653
this._onlineDetectors$.bubbleTo(this);
5754
this._lhcPeriodStatistics$.bubbleTo(this);
@@ -82,12 +79,15 @@ export class RunsPerLhcPeriodOverviewModel extends FixedPdpBeamTypeRunsOverviewM
8279
return;
8380
}
8481

85-
await this._fetchLhcPeriod().then(() => {
86-
this._lhcPeriodStatistics$.getCurrent().match({
87-
Success: ({ pdpBeamTypes }) => this.setPdpBeamTypes(pdpBeamTypes),
88-
Other: () => null,
89-
});
82+
await this._fetchLhcPeriod();
83+
this._lhcPeriodStatistics$.getCurrent().match({
84+
Success: ({ pdpBeamTypes }) => this.setPdpBeamTypes(pdpBeamTypes),
85+
Other: () => null,
9086
});
87+
88+
this.registerDetectorsForQcFlagsDataExport(this._syncDetectors$);
89+
this.registerObservablesQcSummaryDependsOn(this._syncDetectors$);
90+
9191
super.load();
9292
}
9393

lib/public/views/Runs/RunsModel.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,14 @@ export class RunsModel extends Observable {
142142
loadPerSimulationPassOverview({ simulationPassId }) {
143143
if (!this._perSimulationPassOverviewModel.pagination.isInfiniteScrollEnabled) {
144144
this._perSimulationPassOverviewModel.simulationPassId = parseInt(simulationPassId, 10);
145-
this._perSimulationPassOverviewModel.load();
145+
if (this._perSimulationPassOverviewModel.pagination._defaultItemsPerPage) {
146+
/**
147+
* If the default items per page is set, it means model has loaded already once,
148+
* so the pagination trigger will not refresh the data.
149+
* Thus, we need to trigger the load here.
150+
*/
151+
this._perSimulationPassOverviewModel.load();
152+
}
146153
}
147154
}
148155

lib/public/views/Runs/RunsPerSimulationPass/RunsPerSimulationPassOverviewModel.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ export class RunsPerSimulationPassOverviewModel extends FixedPdpBeamTypeRunsOver
3131

3232
this._detectors$ = rctDetectorsProvider.qc$;
3333

34-
this.registerObservablesQcSummaryDependsOn(this._detectors$);
35-
this.registerDetectorsNotBadFractionFilterModels(this._detectors$);
36-
this.registerDetectorsForQcFlagsDataExport(this._detectors$);
37-
3834
this._detectors$.bubbleTo(this);
3935
this._simulationPass$.bubbleTo(this);
4036
}
@@ -61,12 +57,16 @@ export class RunsPerSimulationPassOverviewModel extends FixedPdpBeamTypeRunsOver
6157
return;
6258
}
6359

64-
this._fetchSimulationPass().then(() => {
65-
this._simulationPass$.getCurrent().match({
66-
Success: ({ pdpBeamTypes }) => this.setPdpBeamTypes(pdpBeamTypes),
67-
Other: () => null,
68-
});
60+
await this._fetchSimulationPass();
61+
this._simulationPass$.getCurrent().match({
62+
Success: ({ pdpBeamTypes }) => this.setPdpBeamTypes(pdpBeamTypes),
63+
Other: () => null,
6964
});
65+
66+
this.registerDetectorsNotBadFractionFilterModels(this._detectors$);
67+
this.registerDetectorsForQcFlagsDataExport(this._detectors$);
68+
this.registerObservablesQcSummaryDependsOn(this._detectors$);
69+
7070
super.load();
7171
}
7272

0 commit comments

Comments
 (0)