Skip to content

Commit f1478ee

Browse files
committed
Merge branch 'dev' of https://github.com/contentstack/migration-v2-node-server into feature/test-migration
2 parents 7e33ab2 + 377a722 commit f1478ee

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

api/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const watcher = chokidar.watch(config.LOG_FILE_PATH, {
2626
usePolling: true, // Enables polling to detect changes in all environments
2727
interval: 1, // Poll every 100ms (you can adjust this if needed)
2828
awaitWriteFinish: { // Wait for file to finish being written before triggering
29-
stabilityThreshold: 1, // Time to wait before considering the file stable
29+
stabilityThreshold: 10, // Time to wait before considering the file stable
3030
pollInterval: 1, // Interval at which to poll for file stability
3131
},
3232
persistent: true, // Keeps watching the file even after initial change

api/src/services/contentful.service.ts

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { v4 as uuidv4 } from "uuid";
55
import _ from "lodash";
66
import axios from "axios";
77
import jsonpath from "jsonpath";
8-
// import pLimit from 'p-limit';
8+
import pLimit from 'p-limit';
99

1010

1111
import {CHUNK_SIZE, MIGRATION_DATA_CONFIG } from "../constants/index.js";
@@ -408,24 +408,17 @@ const createAssets = async (packagePath: any, destination_stack_id:string, proje
408408
const assets = JSON.parse(data)?.assets;
409409

410410
if (assets && assets.length > 0) {
411-
const tasks = assets.map(
412-
async (asset: any, index: any) =>
413-
saveAsset(asset, failedJSON, assetData, metadata, projectId, destination_stack_id, 0)
411+
const limit = pLimit(10); // Limit concurrent operations to 10
412+
const tasks = assets.map((asset: any) =>
413+
limit(() => saveAsset(asset, failedJSON, assetData, metadata, projectId, destination_stack_id, 0))
414414
);
415415

416-
// This code is intentionally commented out
417-
// for testing purposes.
418-
419-
// const limit = pLimit(10); // Limit concurrent operations to 10
420-
// const tasks = assets.map((asset: any) =>
421-
// limit(() => saveAsset(asset, failedJSON, assetData, metadata, projectId, destination_stack_id, 0))
422-
// );
423-
// await Promise.all(tasks);
424-
425416
await Promise.all(tasks);
426417
const assetMasterFolderPath = path.join(assetsSave, ASSETS_FAILED_FILE);
427418

428419
await writeOneFile(path.join(assetsSave, ASSETS_SCHEMA_FILE), assetData);
420+
// This code is intentionally commented out
421+
429422
// const chunks: { [key: string]: any } = makeChunks(assetData);
430423
// const refs: any = {};
431424

@@ -653,12 +646,6 @@ const createEntry = async (packagePath: any, destination_stack_id:string, projec
653646
entryData[name][locale][id][formattedKey] = value;
654647
}
655648
);
656-
const message = getLogMessage(
657-
srcFunc,
658-
`Entry title "${entryData[name][locale][id]?.title}"(${name}) in the ${locale} locale has been successfully transformed.`,
659-
{}
660-
)
661-
customLogger(projectId, destination_stack_id, 'info', message)
662649
});
663650
});
664651

@@ -673,6 +660,14 @@ const createEntry = async (packagePath: any, destination_stack_id:string, projec
673660
values as { [key: string]: any }
674661
)) {
675662
const chunks = await makeChunks(localeValues);
663+
for (const [entryKey, entryValue] of Object.entries(localeValues)){
664+
const message = getLogMessage(
665+
srcFunc,
666+
`Entry title "${(entryValue as { title: string })?.title}"(${key}) in the ${localeKey} locale has been successfully transformed.`,
667+
{}
668+
);
669+
await customLogger(projectId, destination_stack_id, "info", message);
670+
}
676671
const refs: { [key: string]: any } = {};
677672
let chunkIndex = 1;
678673
const filePath = path.join(

0 commit comments

Comments
 (0)