Skip to content

Commit 9cb8724

Browse files
Houwie7000gradutaisaachilly
authored
[O2B-1509] LHCfills scheme name filter (#2046)
* add widget for filtering option for filling scheme name * update GetAllLhcFillUseCase to filter by filling scheme name if parameter provided --------- Co-authored-by: George Raduta <george.raduta@cern.ch> Co-authored-by: Isaac Hill <71404865+isaachilly@users.noreply.github.com>
1 parent bda5d52 commit 9cb8724

7 files changed

Lines changed: 71 additions & 3 deletions

File tree

lib/domain/dtos/filters/LhcFillsFilterDto.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ exports.LhcFillsFilterDto = Joi.object({
2323
}),
2424
runDuration: validateTimeDuration,
2525
beamDuration: validateTimeDuration,
26+
schemeName: Joi.string().trim().max(64),
2627
beamTypes: Joi.string()
2728
.trim()
2829
.custom(validateBeamTypes)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE Trg. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-Trg.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
import { rawTextFilter } from '../common/filters/rawTextFilter.js';
15+
16+
/**
17+
* Component to filter LHC-fills by scheme name
18+
*
19+
* @param {RawTextFilterModel} filterModel the filter model
20+
* @returns {Component} the text field
21+
*/
22+
export const schemeNameFilter = (filterModel) => rawTextFilter(
23+
filterModel,
24+
{ classes: ['w-100'], placeholder: 'e.g. Single_12b_8_1024_8_2018' },
25+
);

lib/public/views/LhcFills/ActiveColumns/lhcFillsActiveColumns.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { toggleStableBeamOnlyFilter } from '../../../components/Filters/LhcFills
2727
import { fillNumberFilter } from '../../../components/Filters/LhcFillsFilter/fillNumberFilter.js';
2828
import { durationFilter } from '../../../components/Filters/LhcFillsFilter/durationFilter.js';
2929
import { beamTypeFilter } from '../../../components/Filters/LhcFillsFilter/beamTypeFilter.js';
30+
import { schemeNameFilter } from '../../../components/Filters/LhcFillsFilter/schemeNameFilter.js';
3031

3132
/**
3233
* List of active columns for a lhc fills table
@@ -175,6 +176,7 @@ export const lhcFillsActiveColumns = {
175176
visible: true,
176177
size: 'w-10',
177178
format: (value) => value ? value : '-',
179+
filter: (lhcFillModel) => schemeNameFilter(lhcFillModel.filteringModel.get('schemeName')),
178180
balloon: true,
179181
},
180182
runs: {

lib/public/views/LhcFills/Overview/LhcFillsOverviewModel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class LhcFillsOverviewModel extends OverviewPageModel {
4040
runDuration: new TextComparisonFilterModel(),
4141
hasStableBeams: new StableBeamFilterModel(),
4242
beamTypes: new BeamTypeFilterModel(),
43+
schemeName: new RawTextFilterModel(),
4344
});
4445

4546
this._filteringModel.observe(() => this._applyFilters());

lib/usecases/lhcFill/GetAllLhcFillsUseCase.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class GetAllLhcFillsUseCase {
4747
let associatedStatisticsRequired = false;
4848

4949
if (filter) {
50-
const { hasStableBeams, fillNumbers, beamDuration, runDuration, beamTypes } = filter;
50+
const { hasStableBeams, fillNumbers, schemeName, beamDuration, runDuration, beamTypes } = filter;
5151
if (hasStableBeams) {
5252
// For now, if a stableBeamsStart is present, then a beam is stable
5353
queryBuilder.where('stableBeamsStart').not().is(null);
@@ -81,7 +81,6 @@ class GetAllLhcFillsUseCase {
8181
}
8282
}
8383

84-
// Beam duration filter, limit and corresponding operator.
8584
if (beamDuration?.limit !== undefined && beamDuration?.operator) {
8685
queryBuilder.where('stableBeamsDuration').applyOperator(beamDuration.operator, beamDuration.limit);
8786
}
@@ -90,6 +89,10 @@ class GetAllLhcFillsUseCase {
9089
const beamTypesArray = beamTypes.split(',');
9190
queryBuilder.where('beamType').oneOf(beamTypesArray);
9291
}
92+
93+
if (schemeName) {
94+
queryBuilder.where('filling_scheme_name').substring(schemeName);
95+
}
9396
}
9497

9598
const { count, rows } = await TransactionHelper.provide(async () => {
@@ -118,6 +121,7 @@ class GetAllLhcFillsUseCase {
118121
rows[rowIndex].runs = [];
119122
}
120123
}
124+
121125
return {
122126
count,
123127
lhcFills: rows.map(lhcFillAdapter.toEntity),

test/lib/usecases/lhcFill/GetAllLhcFillsUseCase.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,28 @@ module.exports = () => {
101101
});
102102
})
103103

104+
it('should only contain matching scheme name, one precise', async () => {
105+
getAllLhcFillsDto.query = { filter: { hasStableBeams: true, schemeName: 'schemename' } };
106+
const { lhcFills } = await new GetAllLhcFillsUseCase().execute(getAllLhcFillsDto);
107+
108+
expect(lhcFills).to.be.an('array').and.lengthOf(3)
109+
110+
lhcFills.forEach((lhcFill) => {
111+
expect(lhcFill.fillingSchemeName).to.equal('schemename')
112+
});
113+
})
114+
115+
it('should only contain matching scheme name, one partial', async () => {
116+
getAllLhcFillsDto.query = { filter: { schemeName: '25ns_2352b_2340_2004_2133' } };
117+
const { lhcFills } = await new GetAllLhcFillsUseCase().execute(getAllLhcFillsDto);
118+
119+
expect(lhcFills).to.be.an('array').and.lengthOf(1)
120+
121+
lhcFills.forEach((lhcFill) => {
122+
expect(lhcFill.fillingSchemeName).to.equal('25ns_2352b_2340_2004_2133_108bpi_24inj')
123+
});
124+
})
125+
104126
// Beam duration filter tests
105127
it('should only contain specified stable beam durations, < 12:00:00', async () => {
106128
getAllLhcFillsDto.query = { filter: { beamDuration: {limit: '43200', operator: '<'} } };

test/public/lhcFills/overview.test.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ module.exports = () => {
256256
const meanRunDurationExpect = { selector: 'tbody tr:nth-child(1) td:nth-child(6)', value: '01:40:00' };
257257
const totalRunsDurationExpect = { selector: 'tbody tr:nth-child(1) td:nth-child(7)', value: '05:00:00' };
258258
const efficiencyExpect = { selector: 'tbody tr:nth-child(1) td:nth-child(8)', value: '41.67%' };
259+
const schemeNameExpect = { selector: '#row6-fillingSchemeName > div:nth-child(1) > div:nth-child(1)', value: 'Single_12b_8_1024_8_2018'};
259260

260261
await goToPage(page, 'lhc-fill-overview');
261262

@@ -265,6 +266,7 @@ module.exports = () => {
265266
await expectInnerText(page, meanRunDurationExpect.selector, meanRunDurationExpect.value);
266267
await expectInnerText(page, totalRunsDurationExpect.selector, totalRunsDurationExpect.value);
267268
await expectInnerText(page, efficiencyExpect.selector, efficiencyExpect.value);
269+
await expectInnerText(page, schemeNameExpect.selector, schemeNameExpect.value);
268270
});
269271

270272
it('should successfully display filter elements', async () => {
@@ -276,7 +278,7 @@ module.exports = () => {
276278
const filterRunDurationPlaceholderExpect = {selector: '#run-duration-filter-operand', value: 'e.g 16:14:15 (HH:MM:SS)'};
277279
const filterSBDurationOperatorExpect = { value: true };
278280
const filterBeamTypeExpect = {selector: 'div.flex-row:nth-child(5) > div:nth-child(1)', value: 'Beam Type'}
279-
281+
const filterSchemeNamePlaceholderExpect = {selector: '.fillingSchemeName-filter input', value: 'e.g. Single_12b_8_1024_8_2018'}
280282

281283
await goToPage(page, 'lhc-fill-overview');
282284
// Open the filtering panel
@@ -290,6 +292,7 @@ module.exports = () => {
290292
await expectInnerText(page, filterRunDurationExpect.selector, filterRunDurationExpect.value);
291293
await expectAttributeValue(page, filterRunDurationPlaceholderExpect.selector, 'placeholder', filterRunDurationPlaceholderExpect.value);
292294
await expectInnerText(page, filterBeamTypeExpect.selector, filterBeamTypeExpect.value);
295+
await expectAttributeValue(page, filterSchemeNamePlaceholderExpect.selector, 'placeholder', filterSchemeNamePlaceholderExpect.value);
293296
});
294297

295298
it('should successfully un-apply Stable Beam filter menu', async () => {
@@ -350,4 +353,14 @@ module.exports = () => {
350353
await pressElement(page, filterBeamTypePb_Pb);
351354
await waitForTableLength(page, 2);
352355
});
356+
357+
it('should successfully apply scheme name filter', async () => {
358+
const filterSchemeNameInputField= '.fillingSchemeName-filter input';
359+
await goToPage(page, 'lhc-fill-overview');
360+
await waitForTableLength(page, 5);
361+
362+
await openFilteringPanel(page);
363+
await fillInput(page, filterSchemeNameInputField, 'Single_12b_8_1024_8_2018', ['change']);
364+
await waitForTableLength(page, 1);
365+
});
353366
};

0 commit comments

Comments
 (0)