Skip to content

Commit 56cb4e8

Browse files
committed
[O2B-1508] Rename beamType filter to beamTypes
Rename the beamType filter to beamTypes and update related code.
1 parent 11a371e commit 56cb4e8

7 files changed

Lines changed: 21 additions & 21 deletions

File tree

lib/domain/dtos/filters/LhcFillsFilterDto.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
const Joi = require('joi');
1414
const { validateRange, RANGE_INVALID } = require('../../../utilities/rangeUtils');
15-
const { validateBeamType, BEAM_TYPE_INVALID } = require('../../../utilities/beamTypeUtils');
15+
const { validateBeamTypes, BEAM_TYPE_INVALID } = require('../../../utilities/beamTypeUtils');
1616
const { validateTimeDuration } = require('../../../utilities/validateTime');
1717

1818
exports.LhcFillsFilterDto = Joi.object({
@@ -23,9 +23,9 @@ exports.LhcFillsFilterDto = Joi.object({
2323
}),
2424
runDuration: validateTimeDuration,
2525
beamDuration: validateTimeDuration,
26-
beamType: Joi.string()
26+
beamTypes: Joi.string()
2727
.trim()
28-
.custom(validateBeamType)
28+
.custom(validateBeamTypes)
2929
.messages({
3030
[BEAM_TYPE_INVALID]: '{{#message}}',
3131
'string.base': 'Beam type must be a string',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export const lhcFillsActiveColumns = {
162162
visible: true,
163163
size: 'w-8',
164164
format: (value) => formatBeamType(value),
165-
filter: (lhcFillModel) => beamTypeFilter(lhcFillModel.filteringModel.get('beamType')),
165+
filter: (lhcFillModel) => beamTypeFilter(lhcFillModel.filteringModel.get('beamTypes')),
166166
},
167167
collidingBunches: {
168168
name: 'Colliding bunches',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class LhcFillsOverviewModel extends OverviewPageModel {
3939
beamDuration: new TextComparisonFilterModel(),
4040
runDuration: new TextComparisonFilterModel(),
4141
hasStableBeams: new StableBeamFilterModel(),
42-
beamType: new BeamTypeFilterModel(),
42+
beamTypes: new BeamTypeFilterModel(),
4343
});
4444

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

lib/usecases/lhcFill/GetAllLhcFillsUseCase.js

Lines changed: 4 additions & 4 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, beamType } = filter;
50+
const { hasStableBeams, fillNumbers, 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);
@@ -86,9 +86,9 @@ class GetAllLhcFillsUseCase {
8686
queryBuilder.where('stableBeamsDuration').applyOperator(beamDuration.operator, beamDuration.limit);
8787
}
8888

89-
if (beamType) {
90-
const beamTypes = beamType.split(',');
91-
queryBuilder.where('beamType').oneOf(beamTypes);
89+
if (beamTypes) {
90+
const beamTypesArray = beamTypes.split(',');
91+
queryBuilder.where('beamType').oneOf(beamTypesArray);
9292
}
9393
}
9494

lib/utilities/beamTypeUtils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ export const BEAM_TYPE_INVALID = 'beamType.invalid';
1717
* Validates beam types to have correct format
1818
* Expects a string containing comma separated values.
1919
*
20-
* @param {string} value The value to validate
20+
* @param {string} value Beam types string to validate
2121
* @param {*} helpers The helpers object
2222
* @returns {string} The value if validation passes
2323
*/
24-
export const validateBeamType = (value, helpers) => {
24+
export const validateBeamTypes = (value, helpers) => {
2525
const beamTypes = value.split(',');
2626

2727
for (const type of beamTypes) {

test/api/lhcFills.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ module.exports = () => {
522522

523523
it('should return 200 and an LHCFill array for beam types filter, correct', (done) => {
524524
request(server)
525-
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[beamType]=Pb-Pb')
525+
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[beamTypes]=Pb-Pb')
526526
.expect(200)
527527
.end((err, res) => {
528528
if (err) {
@@ -539,7 +539,7 @@ module.exports = () => {
539539

540540
it('should return 200 and an LHCFill array for beam types filter, multiple correct', (done) => {
541541
request(server)
542-
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[beamType]=Pb-Pb,p-p,p-Pb')
542+
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[beamTypes]=Pb-Pb,p-p,p-Pb')
543543
.expect(200)
544544
.end((err, res) => {
545545
if (err) {
@@ -557,7 +557,7 @@ module.exports = () => {
557557
// API accepts filters that do not exist, this is because it does not affect the results
558558
it('should return 200 for beam types filter, one wrong', (done) => {
559559
request(server)
560-
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[beamType]=Pb-Pb,Hello-World,p-p,p-Pb')
560+
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[beamTypes]=Pb-Pb,Hello-World,p-p,p-Pb')
561561
.expect(200)
562562
.end((err, res) => {
563563
if (err) {
@@ -574,7 +574,7 @@ module.exports = () => {
574574

575575
it('should return 200 and an empty LHC Fill array for beam types filter that does not exist', (done) => {
576576
request(server)
577-
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[beamType]=Hello-World')
577+
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[beamTypes]=Hello-World')
578578
.expect(200)
579579
.end((err, res) => {
580580
if (err) {
@@ -589,7 +589,7 @@ module.exports = () => {
589589

590590
it('should return 400 for beam types filter that is empty', (done) => {
591591
request(server)
592-
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[beamType]=')
592+
.get('/api/lhcFills?page[offset]=0&page[limit]=15&filter[beamTypes]=')
593593
.expect(400)
594594
.end((err, res) => {
595595
if (err) {
@@ -599,7 +599,7 @@ module.exports = () => {
599599

600600
const { errors: [error] } = res.body;
601601
expect(error.title).to.equal('Invalid Attribute');
602-
expect(error.detail).to.equal('"query.filter.beamType" is not allowed to be empty');
602+
expect(error.detail).to.equal('"query.filter.beamTypes" is not allowed to be empty');
603603
done();
604604
});
605605
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ module.exports = () => {
256256
})
257257

258258
it('should only contain specified beam type, {p-p}', async () => {
259-
getAllLhcFillsDto.query = { filter: { beamType: 'p-p' } };
259+
getAllLhcFillsDto.query = { filter: { beamTypes: 'p-p' } };
260260
const { lhcFills } = await new GetAllLhcFillsUseCase().execute(getAllLhcFillsDto)
261261

262262
expect(lhcFills).to.be.an('array').and.lengthOf(2)
@@ -268,7 +268,7 @@ module.exports = () => {
268268
it('should only contain specified beam types, {p-p, PROTON-PROTON, Pb-Pb}', async () => {
269269
const beamTypes = ['p-p', 'PROTON-PROTON', 'Pb-Pb']
270270

271-
getAllLhcFillsDto.query = { filter: { beamType: beamTypes.join(',') } };
271+
getAllLhcFillsDto.query = { filter: { beamTypes: beamTypes.join(',') } };
272272
const { lhcFills } = await new GetAllLhcFillsUseCase().execute(getAllLhcFillsDto)
273273

274274
expect(lhcFills).to.be.an('array').and.lengthOf(4)
@@ -280,7 +280,7 @@ module.exports = () => {
280280
it('should ignore unknown beam types, {p-p, Hello-world, Pb-Pb}', async () => {
281281
const beamTypes = ['p-p', 'Hello-world', 'Pb-Pb']
282282

283-
getAllLhcFillsDto.query = { filter: { beamType: beamTypes.join(',') } };
283+
getAllLhcFillsDto.query = { filter: { beamTypes: beamTypes.join(',') } };
284284
const { lhcFills } = await new GetAllLhcFillsUseCase().execute(getAllLhcFillsDto)
285285

286286
expect(lhcFills).to.be.an('array').and.lengthOf(3)
@@ -290,7 +290,7 @@ module.exports = () => {
290290
})
291291

292292
it('should be empty with unknown beam type, {Hello-world}', async () => {
293-
getAllLhcFillsDto.query = { filter: { beamType: 'Hello-world' } };
293+
getAllLhcFillsDto.query = { filter: { beamTypes: 'Hello-world' } };
294294
const { lhcFills } = await new GetAllLhcFillsUseCase().execute(getAllLhcFillsDto)
295295

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

0 commit comments

Comments
 (0)