Skip to content

Commit ef9ca8a

Browse files
authored
[O2B-1460] Filtering on Runs per LHC Period overview page (#1957)
* A * refactor * cleanup * WIP * add test * add naviagtion util * fix navigatin * fix, cleanup * fix resetting on leaving page * refactor, use lhcPeriodId * cleanup * refactor * fix * a * a * test fixes * remove artifcat * rename lhcPeriod to lhPeriodStatistics * fix test
1 parent e40cbb4 commit ef9ca8a

6 files changed

Lines changed: 173 additions & 83 deletions

File tree

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

Lines changed: 72 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,38 +48,78 @@ export class RunsPerLhcPeriodOverviewModel extends RunsWithQcModel {
4848

4949
this._syncDetectors$.bubbleTo(this);
5050

51+
this._lhcPeriodId = null;
52+
this._lhcPeriodStatistics$ = new ObservableData(RemoteData.notAsked());
53+
this._lhcPeriodStatistics$.bubbleTo(this);
54+
5155
this._tabbedPanelModel = new RunsPerLhcPeriodTabbedPanelModel();
5256
this._tabbedPanelModel.bubbleTo(this);
5357
}
5458

59+
/**
60+
* Fetch LHC period data which runs are fetched
61+
* @return {Promise<void>} promise
62+
*/
63+
async _fetchLhcPeriod() {
64+
this._lhcPeriodStatistics$.setCurrent(RemoteData.loading());
65+
try {
66+
const { data: [lhcPeriodStatistics] } = await jsonFetch(`/api/lhcPeriodsStatistics?filter[ids][]=${this._lhcPeriodId}`);
67+
this._lhcPeriodStatistics$.setCurrent(RemoteData.success(lhcPeriodStatistics));
68+
} catch (error) {
69+
this._lhcPeriodStatistics$.setCurrent(RemoteData.failure(error));
70+
}
71+
}
72+
73+
/**
74+
* @inheritdoc
75+
*/
76+
async load() {
77+
if (!this._lhcPeriodId) {
78+
return;
79+
}
80+
81+
await this._fetchLhcPeriod();
82+
super.load();
83+
}
84+
5585
/**
5686
* @inheritdoc
5787
*/
5888
getRootEndpoint() {
5989
return buildUrl(super.getRootEndpoint(), {
6090
filter: {
61-
lhcPeriods: this._lhcPeriodName,
91+
lhcPeriodIds: [this._lhcPeriodId],
6292
runQualities: 'good',
6393
definitions: 'PHYSICS',
6494
},
6595
});
6696
}
6797

6898
/**
69-
* Get name of current lhc period which runs are fetched
99+
* Get LHC period which runs are fetched
100+
*/
101+
get lhcPeriodStatistics() {
102+
return this._lhcPeriodStatistics$.getCurrent();
103+
}
104+
105+
/**
106+
* Set id of current LHC period which runs are fetched
107+
*
108+
* @param {string} lhcPeriodId id of a LHC period
70109
*/
71-
get lhcPeriodName() {
72-
return this._lhcPeriodName;
110+
set lhcPeriodId(lhcPeriodId) {
111+
this._lhcPeriodId = lhcPeriodId;
112+
this._tabbedPanelModel.lhcPeriodId = lhcPeriodId;
73113
}
74114

75115
/**
76-
* Set name of current lhc period which runs are fetched
116+
* Set mcReproducibleAsNotBad flag
77117
*
78-
* @param {string} lhcPeriodName name of LHC period
118+
* @param {boolean} mcReproducibleAsNotBad new value
79119
*/
80-
set lhcPeriodName(lhcPeriodName) {
81-
this._lhcPeriodName = lhcPeriodName;
82-
this._tabbedPanelModel.lhcPeriodName = lhcPeriodName;
120+
setMcReproducibleAsNotBad(mcReproducibleAsNotBad) {
121+
super.setMcReproducibleAsNotBad(mcReproducibleAsNotBad);
122+
this._tabbedPanelModel.mcReproducibleAsNotBad = mcReproducibleAsNotBad;
83123
}
84124

85125
/**
@@ -141,17 +181,18 @@ class RunsPerLhcPeriodTabbedPanelModel extends TabbedPanelModel {
141181
* @return {Promise<void>} resolved once data are fetched
142182
*/
143183
async _fetchSynchronousQcSummary() {
144-
if (this._lhcPeriodName) {
184+
if (this._lhcPeriodId) {
145185
this.currentPanelData = RemoteData.loading();
146186
this.notify();
147187
try {
148-
const { data: [lhcPeriod] } = await jsonFetch(`/api/lhcPeriodsStatistics?filter[names][]=${this._lhcPeriodName}`);
149-
if (!lhcPeriod) {
150-
this.currentPanelData = RemoteData.failure([{ title: `Cannot find LHC period with name '${this._lhcPeriodName}'` }]);
151-
} else {
152-
const { data: qcSummary } = await jsonFetch(`/api/qcFlags/summary?lhcPeriodId=${lhcPeriod.id}`);
153-
this.currentPanelData = RemoteData.success(qcSummary);
154-
}
188+
const { data: qcSummary } = await jsonFetch(buildUrl(
189+
'/api/qcFlags/summary',
190+
{
191+
lhcPeriodId: this._lhcPeriodId,
192+
mcReproducibleAsNotBad: this._mcReproducibleAsNotBad,
193+
},
194+
));
195+
this.currentPanelData = RemoteData.success(qcSummary);
155196
} catch (errors) {
156197
this.currentPanelData = RemoteData.failure(errors);
157198
}
@@ -160,12 +201,22 @@ class RunsPerLhcPeriodTabbedPanelModel extends TabbedPanelModel {
160201
}
161202

162203
/**
163-
* Set LHC period name
204+
* Set LHC period id
205+
*
206+
* @param {id} lhcPeriodId id of LHC period
207+
*/
208+
set lhcPeriodId(lhcPeriodId) {
209+
this._lhcPeriodId = lhcPeriodId;
210+
this._fetchCurrentPanelData();
211+
}
212+
213+
/**
214+
* Set mcReproducibleAsNotBad flag
164215
*
165-
* @param {string} lhcPeriodName name of LHC period
216+
* @param {boolean} mcReproducibleAsNotBad new value
166217
*/
167-
set lhcPeriodName(lhcPeriodName) {
168-
this._lhcPeriodName = lhcPeriodName;
218+
set mcReproducibleAsNotBad(mcReproducibleAsNotBad) {
219+
this._mcReproducibleAsNotBad = mcReproducibleAsNotBad;
169220
this._fetchCurrentPanelData();
170221
}
171222
}

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

Lines changed: 73 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ import { runDetectorsSyncQcActiveColumns } from '../ActiveColumns/runDetectorsSy
2424
import { tabbedPanelComponent } from '../../../components/TabbedPanel/tabbedPanelComponent.js';
2525
import { RUNS_PER_LHC_PERIOD_PANELS_KEYS } from './RunsPerLhcPeriodOverviewModel.js';
2626
import { PdpBeamType } from '../../../domain/enums/PdpBeamType.js';
27+
import { filtersPanelPopover } from '../../../components/Filters/common/filtersPanelPopover.js';
28+
import { runNumbersFilter } from '../../../components/Filters/RunsFilter/runNumbersFilter.js';
29+
import { mergeRemoteData } from '../../../utilities/mergeRemoteData.js';
30+
import errorAlert from '../../../components/common/errorAlert.js';
31+
import spinner from '../../../components/common/spinner.js';
32+
import { mcReproducibleAsNotBadToggle } from '../mcReproducibleAsNotBadToggle.js';
2733
import { exportTriggerAndModal } from '../../../components/common/dataExport/exportTriggerAndModal.js';
2834

2935
const TABLEROW_HEIGHT = 62;
@@ -53,44 +59,29 @@ export const RunsPerLhcPeriodOverviewPage = ({ runs: { perLhcPeriodOverviewModel
5359

5460
const {
5561
items: remoteRuns,
62+
lhcPeriodStatistics: remoteLhcPeriodStatistics,
5663
onlineDetectors: remoteOnlineDetectors,
5764
syncDetectors: remoteSyncDetectors,
58-
lhcPeriodName,
5965
displayOptions,
6066
sortModel,
6167
tabbedPanelModel,
68+
mcReproducibleAsNotBad,
6269
} = perLhcPeriodOverviewModel;
6370

64-
const activeColumns = {
65-
...runsActiveColumns,
66-
...remoteRuns.match({
67-
Success: (runs) => runs.some((run) => run.pdpBeamType === PdpBeamType.LEAD_LEAD)
68-
? inelasticInteractionRateActiveColumnsForPbPb
69-
: {},
70-
Other: () => {},
71-
}),
72-
...remoteRuns.match({
73-
Success: (runs) => runs.some((run) => run.pdpBeamType === PdpBeamType.PROTON_PROTON)
74-
? inelasticInteractionRateActiveColumnsForProtonProton
75-
: {},
76-
Other: () => {},
77-
}),
78-
};
79-
8071
/**
8172
* Render runs table with given detectors' active columns configuration
8273
*
83-
* @param {object} detectorsActiveColumns active columns
74+
* @param {object} activeColumns common acctivte column
75+
* @param {object} detectorsActiveColumns detectors specific columns
8476
* @return {Component} table with pagination
8577
*/
86-
const getTableWithGivenDetectorsColumns = (detectorsActiveColumns) =>
78+
const getTableWithGivenDetectorsColumns = (activeColumns, detectorsActiveColumns) =>
8779
table(
8880

8981
/*
9082
* Columns depends on detectors' list, it's not useful to render the table when detectors are missing
91-
* TODO replace by RemoteData merging
9283
*/
93-
remoteOnlineDetectors.match({ Success: () => remoteRuns, Other: () => remoteOnlineDetectors }),
84+
remoteRuns,
9485
{
9586
...activeColumns,
9687
...detectorsActiveColumns,
@@ -104,37 +95,69 @@ export const RunsPerLhcPeriodOverviewPage = ({ runs: { perLhcPeriodOverviewModel
10495
{ sort: sortModel },
10596
);
10697

107-
return h('.intermediate-flex-column', [
108-
h('.flex-row.justify-between.g2', [
109-
h('h2', `Good, physics runs of ${lhcPeriodName}`),
110-
exportTriggerAndModal(perLhcPeriodOverviewModel.exportModel, modalModel),
111-
]),
112-
...tabbedPanelComponent(
113-
tabbedPanelModel,
114-
{
115-
[RUNS_PER_LHC_PERIOD_PANELS_KEYS.DETECTOR_QUALITIES]: 'Qualities of detectors',
116-
[RUNS_PER_LHC_PERIOD_PANELS_KEYS.SYNCHRONOUS_FLAGS]: 'Synchronous QC flags',
117-
},
118-
{
119-
[RUNS_PER_LHC_PERIOD_PANELS_KEYS.DETECTOR_QUALITIES]:
120-
() => getTableWithGivenDetectorsColumns(runDetectorsQualitiesActiveColumns(
121-
remoteOnlineDetectors.match({ Success: (payload) => payload, Other: () => [] }),
122-
{ profiles: 'runsPerLhcPeriod' },
123-
)),
98+
return h(
99+
'.intermediate-flex-column',
100+
{ onremove: () => perLhcPeriodOverviewModel.reset(false) },
101+
mergeRemoteData([remoteLhcPeriodStatistics, remoteRuns]).match({
102+
NotAsked: () => null,
103+
Failure: (errors) => errorAlert(errors),
104+
Loading: () => spinner(),
105+
Success: ([lhcPeriodStatistics, runs]) => {
106+
const activeColumns = {
107+
...runsActiveColumns,
108+
...runs.some((run) => run.pdpBeamType === PdpBeamType.LEAD_LEAD) ? inelasticInteractionRateActiveColumnsForPbPb : {},
109+
...runs.some((run) => run.pdpBeamType === PdpBeamType.PROTON_PROTON)
110+
? inelasticInteractionRateActiveColumnsForProtonProton : {},
111+
};
124112

125-
[RUNS_PER_LHC_PERIOD_PANELS_KEYS.SYNCHRONOUS_FLAGS]:
126-
(remoteSynchronousQcSummary) => getTableWithGivenDetectorsColumns(runDetectorsSyncQcActiveColumns(
127-
remoteSyncDetectors.match({ Success: (payload) => payload, Other: () => [] }),
113+
return [
114+
h('.flex-row.justify-between.items-center.g2', [
115+
filtersPanelPopover(perLhcPeriodOverviewModel, activeColumns, { profile: 'runsPerLhcPeriod' }),
116+
h('.pl2#runOverviewFilter', runNumbersFilter(perLhcPeriodOverviewModel.filteringModel.get('runNumbers'))),
117+
h('h2', `Good, physics runs of ${lhcPeriodStatistics.lhcPeriod.name}`),
118+
mcReproducibleAsNotBadToggle(
119+
mcReproducibleAsNotBad,
120+
() => perLhcPeriodOverviewModel.setMcReproducibleAsNotBad(!mcReproducibleAsNotBad),
121+
),
122+
exportTriggerAndModal(perLhcPeriodOverviewModel.exportModel, modalModel),
123+
]),
124+
...tabbedPanelComponent(
125+
tabbedPanelModel,
128126
{
129-
profiles: 'runsPerLhcPeriod',
130-
qcSummary: remoteSynchronousQcSummary.match({ Success: (qcSummary) => qcSummary, Other: () => null }),
127+
[RUNS_PER_LHC_PERIOD_PANELS_KEYS.DETECTOR_QUALITIES]: 'Qualities of detectors',
128+
[RUNS_PER_LHC_PERIOD_PANELS_KEYS.SYNCHRONOUS_FLAGS]: 'Synchronous QC flags',
131129
},
132-
)),
133-
},
134-
{
135-
panelClass: ['scroll-auto'],
130+
{
131+
[RUNS_PER_LHC_PERIOD_PANELS_KEYS.DETECTOR_QUALITIES]: () => remoteOnlineDetectors.match({
132+
Success: (onlineDetectors) => getTableWithGivenDetectorsColumns(
133+
activeColumns,
134+
runDetectorsQualitiesActiveColumns(onlineDetectors, { profiles: 'runsPerLhcPeriod' }),
135+
),
136+
NotAsked: () => null,
137+
Failure: (errors) => errorAlert(errors),
138+
Loading: () => spinner(),
139+
}),
140+
141+
[RUNS_PER_LHC_PERIOD_PANELS_KEYS.SYNCHRONOUS_FLAGS]: (remoteSynchronousQcSummary) =>
142+
mergeRemoteData([remoteSynchronousQcSummary, remoteSyncDetectors]).match({
143+
Success: ([synchronousQcSummary, syncDetectors]) => getTableWithGivenDetectorsColumns(
144+
activeColumns,
145+
runDetectorsSyncQcActiveColumns(syncDetectors, {
146+
profiles: 'runsPerLhcPeriod',
147+
qcSummary: synchronousQcSummary,
148+
}),
149+
),
150+
NotAsked: () => null,
151+
Failure: (errors) => errorAlert(errors),
152+
Loading: () => spinner(),
153+
}),
154+
},
155+
{ panelClass: ['scroll-auto'] },
156+
),
157+
paginationComponent(perLhcPeriodOverviewModel.pagination),
158+
];
136159
},
137-
),
138-
paginationComponent(perLhcPeriodOverviewModel.pagination),
139-
]);
160+
}),
161+
162+
);
140163
};

lib/public/views/Runs/RunsModel.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +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 id of the LHC period to display
8989
* @param {string} [params.panel] the key of the panel to display
9090
* @return {void}
9191
*/
92-
loadPerLhcPeriodOverview({ lhcPeriodName, panel }) {
92+
loadPerLhcPeriodOverview({ lhcPeriodId, panel }) {
9393
this._perLhcPeriodOverviewModel.tabbedPanelModel.currentPanelKey = panel;
9494
if (!this._perLhcPeriodOverviewModel.pagination.isInfiniteScrollEnabled) {
95-
this._perLhcPeriodOverviewModel.lhcPeriodName = lhcPeriodName;
95+
this._perLhcPeriodOverviewModel.lhcPeriodId = lhcPeriodId;
9696
this._perLhcPeriodOverviewModel.load();
9797
}
9898
}

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
},

test/public/defaults.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,15 +781,15 @@ module.exports.testTableSortingByColumn = async (page, columnId) => {
781781
const notOrderData = await getColumnCellsInnerTexts(page, columnId);
782782

783783
// Sort in ASCENDING manner
784-
await this.pressElement(page, `th#${columnId}`);
784+
await this.pressElement(page, `th#${columnId}`, true);
785785
this.expectColumnValues(page, columnId, [...notOrderData].sort());
786786

787787
// Sort in DESCENDING manner
788-
await this.pressElement(page, `th#${columnId}`);
788+
await this.pressElement(page, `th#${columnId}`, true);
789789
this.expectColumnValues(page, columnId, [...notOrderData].sort().reverse());
790790

791791
// Revoke sorting
792-
await this.pressElement(page, `th#${columnId}`);
792+
await this.pressElement(page, `th#${columnId}`, true);
793793
this.expectColumnValues(page, columnId, notOrderData);
794794
};
795795

0 commit comments

Comments
 (0)