Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/domain/dtos/filters/LhcFillsFilterDto.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ exports.LhcFillsFilterDto = Joi.object({
runDuration: validateTimeDuration,
beamDuration: validateTimeDuration,
beamType: Joi.string(),
schemeName: Joi.string().trim(),
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @license
* Copyright CERN and copyright holders of ALICE Trg. 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-Trg.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 { rawTextFilter } from '../common/filters/rawTextFilter.js';

/**
* Component to filter LHC-fills by scheme name
*
* @param {RawTextFilterModel} filterModel the filter model
* @returns {Component} the text field
*/
export const schemeNameFilter = (filterModel) => rawTextFilter(
filterModel,
{ classes: ['w-100'], placeholder: 'e.g. Single_12b_8_1024_8_2018' },
);
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { toggleStableBeamOnlyFilter } from '../../../components/Filters/LhcFills
import { fillNumberFilter } from '../../../components/Filters/LhcFillsFilter/fillNumberFilter.js';
import { durationFilter } from '../../../components/Filters/LhcFillsFilter/durationFilter.js';
import { beamTypeFilter } from '../../../components/Filters/LhcFillsFilter/beamTypeFilter.js';
import { schemeNameFilter } from '../../../components/Filters/LhcFillsFilter/schemeNameFilter.js';

/**
* List of active columns for a lhc fills table
Expand Down Expand Up @@ -175,6 +176,7 @@ export const lhcFillsActiveColumns = {
visible: true,
size: 'w-10',
format: (value) => value ? value : '-',
filter: (lhcFillModel) => schemeNameFilter(lhcFillModel.filteringModel.get('schemeName')),
balloon: true,
},
runs: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class LhcFillsOverviewModel extends OverviewPageModel {
runDuration: new TextComparisonFilterModel(),
hasStableBeams: new StableBeamFilterModel(),
beamType: new BeamTypeFilterModel(),
schemeName: new RawTextFilterModel(),
});

this._filteringModel.observe(() => this._applyFilters());
Expand Down
7 changes: 5 additions & 2 deletions lib/usecases/lhcFill/GetAllLhcFillsUseCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GetAllLhcFillsUseCase {
let associatedStatisticsRequired = false;

if (filter) {
const { hasStableBeams, fillNumbers, beamDuration, runDuration, beamType } = filter;
const { hasStableBeams, fillNumbers, schemeName, beamDuration, runDuration, beamType } = filter;
if (hasStableBeams) {
// For now, if a stableBeamsStart is present, then a beam is stable
queryBuilder.where('stableBeamsStart').not().is(null);
Expand All @@ -65,6 +65,10 @@ class GetAllLhcFillsUseCase {
}
}

if (schemeName) {
queryBuilder.where('filling_scheme_name').substring(schemeName);
}

if (runDuration?.limit !== undefined && runDuration?.operator) {
associatedStatisticsRequired = true;
// 00:00:00 aka 0 value is saved in the DB as null (bookkeeping.fill_statistics.runs_coverage)
Expand All @@ -81,7 +85,6 @@ class GetAllLhcFillsUseCase {
}
}

// Beam duration filter, limit and corresponding operator.
if (beamDuration?.limit !== undefined && beamDuration?.operator) {
queryBuilder.where('stableBeamsDuration').applyOperator(beamDuration.operator, beamDuration.limit);
}
Expand Down
1 change: 1 addition & 0 deletions test/api/lhcFills.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ module.exports = () => {
});
});
});

describe('POST /api/lhcFills', () => {
it('should return 201 if valid data is provided', async () => {
const response = await request(server)
Expand Down
22 changes: 22 additions & 0 deletions test/lib/usecases/lhcFill/GetAllLhcFillsUseCase.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,28 @@ module.exports = () => {
});
})

it('should only contain matching scheme name, one precise', async () => {
getAllLhcFillsDto.query = { filter: { hasStableBeams: true, schemeName: 'schemename' } };
const { lhcFills } = await new GetAllLhcFillsUseCase().execute(getAllLhcFillsDto);

expect(lhcFills).to.be.an('array').and.lengthOf(3)

lhcFills.forEach((lhcFill) => {
expect(lhcFill.fillingSchemeName).to.equal('schemename')
});
})

it('should only contain matching scheme name, one partial', async () => {
getAllLhcFillsDto.query = { filter: { schemeName: '25ns_2352b_2340_2004_2133' } };
const { lhcFills } = await new GetAllLhcFillsUseCase().execute(getAllLhcFillsDto);

expect(lhcFills).to.be.an('array').and.lengthOf(1)

lhcFills.forEach((lhcFill) => {
expect(lhcFill.fillingSchemeName).to.equal('25ns_2352b_2340_2004_2133_108bpi_24inj')
});
})

// Beam duration filter tests
it('should only contain specified stable beam durations, < 12:00:00', async () => {
getAllLhcFillsDto.query = { filter: { beamDuration: {limit: '43200', operator: '<'} } };
Expand Down
15 changes: 14 additions & 1 deletion test/public/lhcFills/overview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ module.exports = () => {
const meanRunDurationExpect = { selector: 'tbody tr:nth-child(1) td:nth-child(6)', value: '01:40:00' };
const totalRunsDurationExpect = { selector: 'tbody tr:nth-child(1) td:nth-child(7)', value: '05:00:00' };
const efficiencyExpect = { selector: 'tbody tr:nth-child(1) td:nth-child(8)', value: '41.67%' };
const schemeNameExpect = { selector: '#row6-fillingSchemeName > div:nth-child(1) > div:nth-child(1)', value: 'Single_12b_8_1024_8_2018'};

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

Expand All @@ -265,6 +266,7 @@ module.exports = () => {
await expectInnerText(page, meanRunDurationExpect.selector, meanRunDurationExpect.value);
await expectInnerText(page, totalRunsDurationExpect.selector, totalRunsDurationExpect.value);
await expectInnerText(page, efficiencyExpect.selector, efficiencyExpect.value);
await expectInnerText(page, schemeNameExpect.selector, schemeNameExpect.value);
});

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

const filterSchemeNamePlaceholderExpect = {selector: '.fillingSchemeName-filter input', value: 'e.g. Single_12b_8_1024_8_2018'}

await goToPage(page, 'lhc-fill-overview');
// Open the filtering panel
Expand All @@ -290,6 +292,7 @@ module.exports = () => {
await expectInnerText(page, filterRunDurationExpect.selector, filterRunDurationExpect.value);
await expectAttributeValue(page, filterRunDurationPlaceholderExpect.selector, 'placeholder', filterRunDurationPlaceholderExpect.value);
await expectInnerText(page, filterBeamTypeExpect.selector, filterBeamTypeExpect.value);
await expectAttributeValue(page, filterSchemeNamePlaceholderExpect.selector, 'placeholder', filterSchemeNamePlaceholderExpect.value);
});

it('should successfully un-apply Stable Beam filter menu', async () => {
Expand Down Expand Up @@ -350,4 +353,14 @@ module.exports = () => {
await pressElement(page, filterBeamTypePb_Pb);
await waitForTableLength(page, 2);
});

it('should successfully apply scheme name filter', async () => {
const filterSchemeNameInputField= '.fillingSchemeName-filter input';
await goToPage(page, 'lhc-fill-overview');
await waitForTableLength(page, 5);

await openFilteringPanel(page);
await fillInput(page, filterSchemeNameInputField, 'Single_12b_8_1024_8_2018', ['change']);
await waitForTableLength(page, 1);
});
};
Loading