Skip to content
Merged
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
3 changes: 3 additions & 0 deletions lib/domain/dtos/filters/RunFilterDto.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ exports.RunFilterDto = Joi.object({
nDetectors: IntegerComparisonDto,
nEpns: IntegerComparisonDto,
nFlps: IntegerComparisonDto,
ctfFileCount: IntegerComparisonDto,
tfFileCount: IntegerComparisonDto,
otherFileCount: IntegerComparisonDto,
ddflp: Joi.boolean(),
dcs: Joi.boolean(),
epn: Joi.boolean(),
Expand Down
15 changes: 15 additions & 0 deletions lib/public/views/Runs/ActiveColumns/runsActiveColumns.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,11 @@
ctfFileCount: {
name: 'CTF File Count',
visible: false,
classes: 'w-2 f6 w-wrapped',
filter: (runsOverviewModel) => numericalComparisonFilter(

Check warning on line 608 in lib/public/views/Runs/ActiveColumns/runsActiveColumns.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/ActiveColumns/runsActiveColumns.js#L608

Added line #L608 was not covered by tests
runsOverviewModel.filteringModel.get('ctfFileCount'),
{ selectorPrefix: 'ctfFileCount' },
),
},
ctfFileSize: {
name: 'CTF File Size',
Expand All @@ -612,6 +617,11 @@
tfFileCount: {
name: 'TF File Count',
visible: false,
classes: 'w-2 f6 w-wrapped',
filter: (runsOverviewModel) => numericalComparisonFilter(

Check warning on line 621 in lib/public/views/Runs/ActiveColumns/runsActiveColumns.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/ActiveColumns/runsActiveColumns.js#L621

Added line #L621 was not covered by tests
runsOverviewModel.filteringModel.get('tfFileCount'),
{ selectorPrefix: 'tfFileCount' },
),
},
tfFileSize: {
name: 'TF File Size',
Expand All @@ -620,6 +630,11 @@
otherFileCount: {
name: 'Other File Count',
visible: false,
classes: 'w-2 f6 w-wrapped',
filter: (runsOverviewModel) => numericalComparisonFilter(

Check warning on line 634 in lib/public/views/Runs/ActiveColumns/runsActiveColumns.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Runs/ActiveColumns/runsActiveColumns.js#L634

Added line #L634 was not covered by tests
runsOverviewModel.filteringModel.get('otherFileCount'),
{ selectorPrefix: 'otherFileCount' },
),
},
otherFileSize: {
name: 'Other File Size',
Expand Down
3 changes: 3 additions & 0 deletions lib/public/views/Runs/Overview/RunsOverviewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export class RunsOverviewModel extends OverviewPageModel {
nDetectors: new NumericalComparisonFilterModel({ integer: true }),
nEpns: new NumericalComparisonFilterModel({ integer: true }),
nFlps: new NumericalComparisonFilterModel({ integer: true }),
ctfFileCount: new NumericalComparisonFilterModel({ integer: true }),
tfFileCount: new NumericalComparisonFilterModel({ integer: true }),
otherFileCount: new NumericalComparisonFilterModel({ integer: true }),
odcTopologyFullName: new RawTextFilterModel(),
eorReason: new EorReasonFilterModel(eorReasonTypeProvider.items$),
magnets: new MagnetsFilteringModel(magnetsCurrentLevelsProvider.items$),
Expand Down
30 changes: 18 additions & 12 deletions lib/usecases/run/GetAllRunsUseCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class GetAllRunsUseCase {
nDetectors,
nEpns,
nFlps,
ctfFileCount,
tfFileCount,
otherFileCount,
o2end,
o2start,
odcTopologyFullName,
Expand Down Expand Up @@ -263,18 +266,21 @@ class GetAllRunsUseCase {
if (runQualities) {
filteringQueryBuilder.where('runQuality').oneOf(...runQualities);
}
if (nDetectors) {
const { operator, limit: nDetectorLimit } = nDetectors;
filteringQueryBuilder.where('nDetectors').applyOperator(operator, nDetectorLimit);
}
if (nFlps) {
const { operator, limit: nFlpsLimit } = nFlps;
filteringQueryBuilder.where('nFlps').applyOperator(operator, nFlpsLimit);
}
if (nEpns) {
const { operator, limit: nEpnsLimit } = nEpns;
filteringQueryBuilder.where('nEpns').applyOperator(operator, nEpnsLimit);
}
const fileCountFilters = [
{ field: 'nDetectors', value: nDetectors },
{ field: 'nFlps', value: nFlps },
{ field: 'nEpns', value: nEpns },
{ field: 'ctfFileCount', value: ctfFileCount },
{ field: 'tfFileCount', value: tfFileCount },
{ field: 'otherFileCount', value: otherFileCount },
];
fileCountFilters.forEach(({ field, value }) => {
if (value) {
const { operator, limit } = value;
filteringQueryBuilder.where(field).applyOperator(operator, limit);
}
});

if (ddflp === false) {
filteringQueryBuilder.where('dd_flp').isOrNull(ddflp);
} else if (ddflp === true) {
Expand Down
72 changes: 72 additions & 0 deletions test/lib/usecases/run/GetAllRunsUseCase.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,78 @@ module.exports = () => {
expect(runs).to.have.lengthOf(0);
});

it('should successfully filter on ctf file count number', async () => {
const ctfFileCount = {
operator: '<',
limit: 200,
};
getAllRunsDto.query = { filter: { ctfFileCount } };

let { runs } = await new GetAllRunsUseCase().execute(getAllRunsDto);
expect(runs).to.be.an('array');
expect(runs).to.have.lengthOf(1);

ctfFileCount.operator = '<=';
({ runs } = await new GetAllRunsUseCase().execute(getAllRunsDto));
expect(runs).to.be.an('array');
expect(runs).to.have.lengthOf(2);
expect(runs.every((run) => run.ctfFileCount <= 200)).to.be.true;

ctfFileCount.operator = '=';
({ runs } = await new GetAllRunsUseCase().execute(getAllRunsDto));
expect(runs).to.be.an('array');
expect(runs).to.have.lengthOf(1);
expect(runs.every((run) => run.ctfFileCount === 200)).to.be.true;

ctfFileCount.operator = '>=';
({ runs } = await new GetAllRunsUseCase().execute(getAllRunsDto));
expect(runs).to.be.an('array');
expect(runs).to.have.lengthOf(7);
expect(runs.every((run) => run.ctfFileCount >= 200)).to.be.true;

ctfFileCount.operator = '>';
({ runs } = await new GetAllRunsUseCase().execute(getAllRunsDto));
expect(runs).to.be.an('array');
expect(runs).to.have.lengthOf(6);
expect(runs.every((run) => run.ctfFileCount >= 500)).to.be.true;
});

it('should successfully filter on tf file count number', async () => {
const tfFileCount = {
operator: '<',
limit: 30,
};
getAllRunsDto.query = { filter: { tfFileCount } };

let { runs } = await new GetAllRunsUseCase().execute(getAllRunsDto);
expect(runs).to.be.an('array');
expect(runs).to.have.lengthOf(0);

tfFileCount.operator = '<=';
({ runs } = await new GetAllRunsUseCase().execute(getAllRunsDto));
expect(runs).to.be.an('array');
expect(runs).to.have.lengthOf(7);
expect(runs.every((run) => run.tfFileCount <= 30)).to.be.true;

tfFileCount.operator = '=';
({ runs } = await new GetAllRunsUseCase().execute(getAllRunsDto));
expect(runs).to.be.an('array');
expect(runs).to.have.lengthOf(7);
expect(runs.every((run) => run.tfFileCount === 30)).to.be.true;

tfFileCount.operator = '>=';
({ runs } = await new GetAllRunsUseCase().execute(getAllRunsDto));
expect(runs).to.be.an('array');
expect(runs).to.have.lengthOf(8);
expect(runs.every((run) => run.tfFileCount >= 30)).to.be.true;

tfFileCount.operator = '>';
({ runs } = await new GetAllRunsUseCase().execute(getAllRunsDto));
expect(runs).to.be.an('array');
expect(runs).to.have.lengthOf(1);
expect(runs.every((run) => run.tfFileCount > 30)).to.be.true;
});

it('should successfully return an array, only containing runs found from passed list', async () => {
getAllRunsDto.query = {
filter: {
Expand Down