@@ -10,6 +10,7 @@ const { performBulkPublish, publishEntry, initializeLogger } = require('../consu
1010const retryFailedLogs = require ( '../util/retryfailed' ) ;
1111const { validateFile } = require ( '../util/fs' ) ;
1212const { isEmpty } = require ( '../util' ) ;
13+ const { fetchBulkPublishLimit } = require ( '../util/common-utility' ) ;
1314
1415const queue = getQueue ( ) ;
1516queue . consumer = performBulkPublish ;
@@ -200,6 +201,7 @@ async function getEntries(
200201 environments ,
201202 forceUpdate ,
202203 apiVersion ,
204+ bulkPublishLimit ,
203205 skip = 0 ,
204206) {
205207 let queryParams = {
@@ -223,15 +225,15 @@ async function getEntries(
223225 const flag = await updateEntry ( updatedEntry , locale ) ;
224226 if ( flag ) {
225227 if ( bulkPublish ) {
226- if ( bulkPublishSet . length < 10 ) {
228+ if ( bulkPublishSet . length < bulkPublishLimit ) {
227229 bulkPublishSet . push ( {
228230 uid : entries [ index ] . uid ,
229231 content_type : contentType ,
230232 locale,
231233 publish_details : entries [ index ] . publish_details ,
232234 } ) ;
233235 }
234- if ( bulkPublishSet . length === 10 ) {
236+ if ( bulkPublishSet . length === bulkPublishLimit ) {
235237 await queue . Enqueue ( {
236238 entries : bulkPublishSet ,
237239 locale,
@@ -260,7 +262,7 @@ async function getEntries(
260262 console . log ( `No change Observed for contentType ${ contentType } with entry ${ entries [ index ] . uid } ` ) ;
261263 }
262264
263- if ( index === entriesResponse . items . length - 1 && bulkPublishSet . length > 0 && bulkPublishSet . length < 10 ) {
265+ if ( index === entriesResponse . items . length - 1 && bulkPublishSet . length > 0 && bulkPublishSet . length < bulkPublishLimit ) {
264266 await queue . Enqueue ( {
265267 entries : bulkPublishSet ,
266268 locale,
@@ -277,7 +279,7 @@ async function getEntries(
277279 }
278280 return setTimeout (
279281 async ( ) =>
280- getEntries ( stack , config , schema , contentType , locale , bulkPublish , environments , forceUpdate , apiVersion , skip ) ,
282+ getEntries ( stack , config , schema , contentType , locale , bulkPublish , environments , forceUpdate , apiVersion , bulkPublishLimit , skip ) ,
281283 2000 ,
282284 ) ;
283285 } )
@@ -321,6 +323,7 @@ async function start(
321323 }
322324 } else {
323325 setConfig ( config , bulkPublish ) ;
326+ const bulkPublishLimit = fetchBulkPublishLimit ( stack ?. org_uid ) ;
324327 for ( let i = 0 ; i < contentTypes . length ; i += 1 ) {
325328 getContentTypeSchema ( stack , contentTypes [ i ] )
326329 . then ( async ( schema ) => {
@@ -335,7 +338,8 @@ async function start(
335338 bulkPublish ,
336339 environments ,
337340 forceUpdate ,
338- apiVersion
341+ apiVersion ,
342+ bulkPublishLimit
339343 ) ;
340344 } catch ( err ) {
341345 console . log ( `Failed to get Entries with contentType ${ contentTypes [ i ] } and locale ${ locales [ j ] } ` ) ;
0 commit comments