Skip to content

Commit 79b1927

Browse files
committed
use lhc period Id
1 parent 3b503a1 commit 79b1927

4 files changed

Lines changed: 78 additions & 43 deletions

File tree

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export class RunsPerDataPassOverviewModel extends FixedPdpBeamTypeRunsOverviewMo
4343
}));
4444
}),
4545
}));
46-
this._dataPass = new ObservableData(RemoteData.notAsked());
47-
this._dataPass.bubbleTo(this);
46+
this._dataPass$ = new ObservableData(RemoteData.notAsked());
47+
this._dataPass$.bubbleTo(this);
4848
this._qcSummary$ = new ObservableData(RemoteData.notAsked());
4949
this._qcSummary$.bubbleTo(this);
5050
this._gaqSummary$ = new ObservableData(RemoteData.notAsked());
@@ -120,16 +120,16 @@ export class RunsPerDataPassOverviewModel extends FixedPdpBeamTypeRunsOverviewMo
120120

121121
this._fetchQcSummary();
122122
this._fetchGaqSummary();
123-
await this._fetchDataPass();
124-
this._dataPass.getCurrent().match({
125-
Success: ({ skimmingStage, pdpBeamTypes }) => {
126-
if (skimmingStage === SkimmingStage.SKIMMABLE) {
127-
this._fetchSkimmableRuns();
128-
}
129-
this.setPdpBeamTypes(pdpBeamTypes);
130-
},
131-
Other: () => null,
132-
});
123+
await this._fetchDataPass().then(() =>
124+
this._dataPass$.getCurrent().match({
125+
Success: ({ skimmingStage, pdpBeamTypes }) => {
126+
if (skimmingStage === SkimmingStage.SKIMMABLE) {
127+
this._fetchSkimmableRuns();
128+
}
129+
this.setPdpBeamTypes(pdpBeamTypes);
130+
},
131+
Other: () => null,
132+
}));
133133
super.load();
134134
}
135135

@@ -284,7 +284,7 @@ export class RunsPerDataPassOverviewModel extends FixedPdpBeamTypeRunsOverviewMo
284284
* Get current data pass which runs are fetched
285285
*/
286286
get dataPass() {
287-
return this._dataPass.getCurrent();
287+
return this._dataPass$.getCurrent();
288288
}
289289

290290
/**
@@ -353,12 +353,12 @@ export class RunsPerDataPassOverviewModel extends FixedPdpBeamTypeRunsOverviewMo
353353
* @return {Promise<void>} promise
354354
*/
355355
async _fetchDataPass() {
356-
this._dataPass.setCurrent(RemoteData.loading());
356+
this._dataPass$.setCurrent(RemoteData.loading());
357357
try {
358358
const { items: [dataPass] = [] } = await getRemoteDataSlice(`/api/dataPasses?filter[ids][]=${this._dataPassId}`);
359-
this._dataPass.setCurrent(RemoteData.success(dataPass));
359+
this._dataPass$.setCurrent(RemoteData.success(dataPass));
360360
} catch (error) {
361-
this._dataPass.setCurrent(RemoteData.failure(error));
361+
this._dataPass$.setCurrent(RemoteData.failure(error));
362362
}
363363
}
364364

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

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { buildUrl, RemoteData } from '/js/src/index.js';
1414
import { TabbedPanelModel } from '../../../components/TabbedPanel/TabbedPanelModel.js';
1515
import { detectorsProvider } from '../../../services/detectors/detectorsProvider.js';
1616
import { jsonFetch } from '../../../utilities/fetch/jsonFetch.js';
17+
import { ObservableData } from '../../../utilities/ObservableData.js';
1718
import { FixedPdpBeamTypeRunsOverviewModel } from '../Overview/FixedPdpBeamTypeRunsOverviewModel.js';
1819

1920
export const RUNS_PER_LHC_PERIOD_PANELS_KEYS = {
@@ -35,38 +36,73 @@ export class RunsPerLhcPeriodOverviewModel extends FixedPdpBeamTypeRunsOverviewM
3536
this._detectors$ = detectorsProvider.physical$;
3637
this._detectors$.bubbleTo(this);
3738

39+
this._lhcPeriodId = null;
40+
this._lhcPeriod$ = new ObservableData(RemoteData.notAsked());
41+
this._lhcPeriod$.bubbleTo(this);
42+
3843
this._tabbedPanelModel = new RunsPerLhcPeriodTabbedPanelModel();
3944
this._tabbedPanelModel.bubbleTo(this);
4045
}
4146

47+
/**
48+
* Fetch LHC period data which runs are fetched
49+
* @return {Promise<void>} promise
50+
*/
51+
async _fetchLhcPeriod() {
52+
this._lhcPeriod$.setCurrent(RemoteData.loading());
53+
try {
54+
const { data: [lhcPeriod] } = await jsonFetch(`/api/lhcPeriodsStatistics?filter[ids][]=${this._lhcPeriodId}`);
55+
this._lhcPeriod$.setCurrent(RemoteData.success(lhcPeriod));
56+
} catch (error) {
57+
this._lhcPeriod$.setCurrent(RemoteData.failure(error));
58+
}
59+
}
60+
61+
/**
62+
* @inheritdoc
63+
*/
64+
async load() {
65+
if (!this._lhcPeriodId) {
66+
return;
67+
}
68+
69+
this._fetchLhcPeriod().then(() =>
70+
this._lhcPeriod$.getCurrent().match({
71+
Success: ({ pdpBeamTypes }) => this.setPdpBeamTypes(pdpBeamTypes),
72+
Other: () => null,
73+
}));
74+
75+
super.load();
76+
}
77+
4278
/**
4379
* @inheritdoc
4480
*/
4581
getRootEndpoint() {
4682
return buildUrl(super.getRootEndpoint(), {
4783
filter: {
48-
lhcPeriods: this._lhcPeriodName,
84+
lhcPeriodIds: [this._lhcPeriodId],
4985
runQualities: 'good',
5086
definitions: 'PHYSICS',
5187
},
5288
});
5389
}
5490

5591
/**
56-
* Get name of current lhc period which runs are fetched
92+
* Get LHC period which runs are fetched
5793
*/
58-
get lhcPeriodName() {
59-
return this._lhcPeriodName;
94+
get lhcPeriod() {
95+
return this._lhcPeriod$.getCurrent();
6096
}
6197

6298
/**
63-
* Set name of current lhc period which runs are fetched
99+
* Set id of current LHC period which runs are fetched
64100
*
65-
* @param {string} lhcPeriodName name of LHC period
101+
* @param {string} lhcPeriodId id of a LHC period
66102
*/
67-
set lhcPeriodName(lhcPeriodName) {
68-
this._lhcPeriodName = lhcPeriodName;
69-
this._tabbedPanelModel.lhcPeriodName = lhcPeriodName;
103+
set lhcPeriodId(lhcPeriodId) {
104+
this._lhcPeriodId = lhcPeriodId;
105+
this._tabbedPanelModel.lhcPeriodId = lhcPeriodId;
70106
}
71107

72108
/**
@@ -119,17 +155,17 @@ class RunsPerLhcPeriodTabbedPanelModel extends TabbedPanelModel {
119155
* @return {Promise<void>} resolved once data are fetched
120156
*/
121157
async _fetchSynchronousQcSummary() {
122-
if (this._lhcPeriodName) {
158+
if (this._lhcPeriodId) {
123159
this.currentPanelData = RemoteData.loading();
124160
this.notify();
125161
try {
126-
const { data: [lhcPeriod] } = await jsonFetch(`/api/lhcPeriodsStatistics?filter[names][]=${this._lhcPeriodName}`);
127-
if (!lhcPeriod) {
128-
this.currentPanelData = RemoteData.failure([{ title: `Cannot find LHC period with name '${this._lhcPeriodName}'` }]);
129-
} else {
130-
const { data: qcSummary } = await jsonFetch(`/api/qcFlags/summary?lhcPeriodId=${lhcPeriod.id}`);
131-
this.currentPanelData = RemoteData.success(qcSummary);
132-
}
162+
const { data: qcSummary } = await jsonFetch(buildUrl(
163+
'/api/qcFlags/summary',
164+
{
165+
lhcPeriodId: this._lhcPeriodId,
166+
},
167+
));
168+
this.currentPanelData = RemoteData.success(qcSummary);
133169
} catch (errors) {
134170
this.currentPanelData = RemoteData.failure(errors);
135171
}
@@ -138,12 +174,12 @@ class RunsPerLhcPeriodTabbedPanelModel extends TabbedPanelModel {
138174
}
139175

140176
/**
141-
* Set LHC period name
177+
* Set LHC period id
142178
*
143-
* @param {string} lhcPeriodName name of LHC period
179+
* @param {id} lhcPeriodId id of LHC period
144180
*/
145-
set lhcPeriodName(lhcPeriodName) {
146-
this._lhcPeriodName = lhcPeriodName;
181+
set lhcPeriodId(lhcPeriodId) {
182+
this._lhcPeriodId = lhcPeriodId;
147183
this._fetchCurrentPanelData();
148184
}
149185
}

lib/public/views/Runs/RunsModel.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,14 @@ export class RunsModel extends Observable {
8585
/**
8686
* Load runs overview data
8787
* @param {object} params the parameters for the model
88-
* @param {string} params.lhcPeriodName the name of the LHC period to display
88+
* @param {string} params.lhcPeriodId the name of the LHC period to display
8989
* @param {string} params.panel the key of the panel to display
90-
* @param {string} params.pdpBeamTypesx the key of the panel to display
9190
* @return {void}
9291
*/
93-
loadPerLhcPeriodOverview({ lhcPeriodName, panel }) {
92+
loadPerLhcPeriodOverview({ lhcPeriodId, panel }) {
9493
this._perLhcPeriodOverviewModel.tabbedPanelModel.currentPanelKey = panel;
9594
if (!this._perLhcPeriodOverviewModel.pagination.isInfiniteScrollEnabled) {
96-
this._perLhcPeriodOverviewModel.lhcPeriodName = lhcPeriodName;
95+
this._perLhcPeriodOverviewModel.lhcPeriodId = lhcPeriodId;
9796
this._perLhcPeriodOverviewModel.load();
9897
}
9998
}

lib/public/views/lhcPeriods/ActiveColumns/lhcPeriodsActiveColumns.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ export const lhcPeriodsActiveColumns = {
4040
associatedRuns: {
4141
name: 'Runs',
4242
visible: true,
43-
format: (_, { name, runsCount }) =>
43+
format: (_, { id, runsCount }) =>
4444
runsCount === 0
4545
? 'No runs'
4646
: frontLink(
4747
badge(runsCount),
4848
'runs-per-lhc-period',
49-
{ lhcPeriodName: name },
49+
{ lhcPeriodId: id },
5050
),
5151
classes: 'w-10',
5252
},

0 commit comments

Comments
 (0)