spec: fix partioning logic for odd number of files
If there are an odd number of files to split, the last file would go into a bucket outside of the valid range. Fix this by using Math.ceil() instead of Math.floor() flag = none Change-Id: I51b8e8f66a87c8cd725441a4b10e9a77426223e4 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/242785 Reviewed-by: James Butters <jbutters@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> QA-Review: Aaron Ogata <aogata@instructure.com> Product-Review: Aaron Ogata <aogata@instructure.com>
This commit is contained in:
parent
9c0586c472
commit
9089b33063
|
@ -18,6 +18,7 @@
|
|||
|
||||
process.env.NODE_ENV = 'test'
|
||||
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
|
@ -81,13 +82,15 @@ const isPartitionMatch = (resource, partitions, partitionIndex) => {
|
|||
const makeSortedPartitions = (arr, partitionCount) => {
|
||||
const sortedArr = arr.sort()
|
||||
const sortedArrLength = sortedArr.length
|
||||
const chunkSize = Math.floor(sortedArrLength / partitionCount)
|
||||
const chunkSize = Math.ceil(sortedArrLength / partitionCount)
|
||||
const R = []
|
||||
|
||||
for (let i = 0; i < sortedArrLength; i += chunkSize) {
|
||||
R.push(sortedArr.slice(i, i + chunkSize))
|
||||
}
|
||||
|
||||
assert(R.length <= partitionCount)
|
||||
|
||||
return R
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue