@trimblemaps/webtools-common
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -20,2 +20,3 @@ /* | ||
const INVALID_CHAR_REGEX = /^[^\^/\\]+$/; | ||
const BATCH_SIZE = 5000; | ||
@@ -811,21 +812,32 @@ //The base import field ES6 class. It holds metadata for an import field (i.e. place name, latitude). | ||
//Add the places without yards (this is batched for performance) | ||
placeCloudService.saveNewPlaces(setId, catId, placesWithoutYards).then(function (response) { | ||
if (!response) { | ||
deferred.resolve(null); | ||
return; | ||
} | ||
//If there are no places with yards, just quit here | ||
if (places.length === 0) { | ||
deferred.resolve({ | ||
setId: setId | ||
}); | ||
return; | ||
} | ||
//Add the places with yards | ||
addPlaceYardRecursiveHelper(0, catId); | ||
}); | ||
processBatch(0); | ||
return deferred.promise; | ||
function processBatch(index) { | ||
if (index >= placesWithoutYards.length) { | ||
//If there are no places with yards, just quit here | ||
if (places.length === 0) { | ||
deferred.resolve({ | ||
setId: setId | ||
}); | ||
return; | ||
} | ||
//Add the places with yards | ||
addPlaceYardRecursiveHelper(0, catId); | ||
} | ||
var batch = placesWithoutYards.slice(index, index + BATCH_SIZE); | ||
index += BATCH_SIZE; | ||
//Add the places without yards (this is batched for performance) | ||
placeCloudService.saveNewPlaces(setId, catId, batch).then(function (response) { | ||
if (!response) { | ||
deferred.resolve(null); | ||
return; | ||
} | ||
processBatch(index); | ||
}); | ||
} | ||
//Initiates the callback chain for adding a single place and its yard data. | ||
@@ -918,3 +930,3 @@ function addPlaceYardRecursiveHelper(index, catId) { | ||
}); | ||
return placeCloudService.deletePlaces(placeIdList); | ||
return placeCloudService.deletePlacesBatch(placeIdList); | ||
//Delete the places in the set | ||
@@ -921,0 +933,0 @@ }).then(function (deleteResponse) { |
@@ -17,2 +17,4 @@ /* globals _ */ | ||
const COMPANY_PLACES_TYPE_ID = 1803; | ||
const PLACES_BATCH_SIZE = 5000; | ||
const DELETE_BATCH_SIZE = 500; | ||
@@ -37,4 +39,6 @@ return { | ||
deletePlaces: deletePlaces, | ||
deletePlacesBatch: deletePlacesBatch, | ||
updatePlace: updatePlace, | ||
movePlaces: movePlaces, | ||
movePlacesBatch: movePlacesBatch, | ||
getYardByYardId: getYardByYardId, | ||
@@ -515,2 +519,21 @@ addOrEditSite: addOrEditSite, | ||
function deletePlacesBatch(placeIdList) { | ||
function processBatch(index) { | ||
if (index >= placeIdList.length) { | ||
return true; | ||
} | ||
var batch = placeIdList.slice(index, index + DELETE_BATCH_SIZE); | ||
index += DELETE_BATCH_SIZE; | ||
return deletePlaces(batch).then(function (response) { | ||
if (response && response.ItemsModified > 0) { | ||
return processBatch(index); | ||
} | ||
else { | ||
return false; | ||
} | ||
}); | ||
} | ||
return processBatch(0); | ||
} | ||
function updatePlace(placeObj) { | ||
@@ -552,2 +575,21 @@ var request = { | ||
function movePlacesBatch(placeIds, destinationSet, catId) { | ||
function processBatch(index) { | ||
if (index >= placeIds.length) { | ||
return true; | ||
} | ||
var batch = placeIds.slice(index, index + PLACES_BATCH_SIZE); | ||
index += PLACES_BATCH_SIZE; | ||
return movePlaces(batch, destinationSet, catId).then(function (response) { | ||
if (response && response.ItemsModified > 0) { | ||
return processBatch(index); | ||
} | ||
else { | ||
return false; | ||
} | ||
}); | ||
} | ||
return processBatch(0); | ||
} | ||
function getCategoryIcons() { | ||
@@ -554,0 +596,0 @@ return [ |
{ | ||
"name": "@trimblemaps/webtools-common", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "scripts": { |
4279395
72819