Skip to content

Commit

Permalink
changed variable names to be more descriptive and remove redundant check
Browse files Browse the repository at this point in the history
  • Loading branch information
Fennne committed Dec 9, 2024
1 parent efbfe5f commit 28ff5b2
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/usecases/run/GetAllRunsUseCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,34 +77,34 @@ class GetAllRunsUseCase {
} = filter;

if (runNumbers) {
const runNumberList = runNumbers.split(SEARCH_ITEMS_SEPARATOR)
.map((runNumber) => runNumber.trim())
const runNumberCriteria = runNumbers.split(SEARCH_ITEMS_SEPARATOR)
.map((runNumbers) => runNumbers.trim())

Check warning on line 81 in lib/usecases/run/GetAllRunsUseCase.js

View check run for this annotation

Codecov / codecov/patch

lib/usecases/run/GetAllRunsUseCase.js#L80-L81

Added lines #L80 - L81 were not covered by tests
.filter(Boolean);

const allRuns = new Set();
const runNumberSet = new Set();

Check warning on line 84 in lib/usecases/run/GetAllRunsUseCase.js

View check run for this annotation

Codecov / codecov/patch

lib/usecases/run/GetAllRunsUseCase.js#L84

Added line #L84 was not covered by tests

runNumberList.forEach((runNumber) => {
runNumberCriteria.forEach((runNumber) => {
if (runNumber.includes('-')) {
const [start, end] = runNumber.split('-').map((n) => parseInt(n, 10));
if (!Number.isNaN(start) && !Number.isNaN(end) && start <= end) {
if (!Number.isNaN(start) && !Number.isNaN(end)) {
for (let i = start; i <= end; i++) {
allRuns.add(i);
runNumberSet.add(i);

Check warning on line 91 in lib/usecases/run/GetAllRunsUseCase.js

View check run for this annotation

Codecov / codecov/patch

lib/usecases/run/GetAllRunsUseCase.js#L86-L91

Added lines #L86 - L91 were not covered by tests
}
}
} else {
const parsedRunNumber = parseInt(runNumber, 10);
if (!Number.isNaN(parsedRunNumber)) {
allRuns.add(parsedRunNumber);
runNumberSet.add(parsedRunNumber);

Check warning on line 97 in lib/usecases/run/GetAllRunsUseCase.js

View check run for this annotation

Codecov / codecov/patch

lib/usecases/run/GetAllRunsUseCase.js#L94-L97

Added lines #L94 - L97 were not covered by tests
}
}
});

const finalRunList = Array.from(allRuns);
if (finalRunList.length) {
if (finalRunList.length > 1) {
filteringQueryBuilder.where('runNumber').oneOf(...finalRunList);
const finalRunNumberList = Array.from(runNumberSet);
if (finalRunNumberList.length) {
if (finalRunNumberList.length > 1) {
filteringQueryBuilder.where('runNumber').oneOf(...finalRunNumberList);

Check warning on line 105 in lib/usecases/run/GetAllRunsUseCase.js

View check run for this annotation

Codecov / codecov/patch

lib/usecases/run/GetAllRunsUseCase.js#L102-L105

Added lines #L102 - L105 were not covered by tests
} else {
const [runNumber] = finalRunList;
const [runNumber] = finalRunNumberList;

Check warning on line 107 in lib/usecases/run/GetAllRunsUseCase.js

View check run for this annotation

Codecov / codecov/patch

lib/usecases/run/GetAllRunsUseCase.js#L107

Added line #L107 was not covered by tests
filteringQueryBuilder.where('runNumber').substring(`${runNumber}`);
}
}
Expand Down

0 comments on commit 28ff5b2

Please sign in to comment.