Skip to content

Commit

Permalink
frontend: Fix crontab expression conversion
Browse files Browse the repository at this point in the history
'/' expression was not calculated correctly when
the number of elements was not divisible by the max
number of elements.
  • Loading branch information
pschlan committed Oct 31, 2023
1 parent 3fc3035 commit 5bd3d38
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions frontend/src/utils/CrontabExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ function convertComponent(array, minElement, maxElement) {
const multiplier = array[1] - array[0];
const multiplierValidated =
array.reduce((prev, cur, index) => prev && (index * multiplier + minElement) === cur, true)
&& array.length === Math.floor((maxElement - minElement + 1) / multiplier);
&& array.length === Math.ceil((maxElement - minElement + 1) / multiplier);
if (multiplierValidated) {
return '*/' + multiplier;
}

return compressSequences(array)
.map(x => Array.isArray(x) ? x.join('-') : '' + x)
.join(',');
Expand Down

0 comments on commit 5bd3d38

Please sign in to comment.