Skip to content
Merged

Dev #438

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const watcher = chokidar.watch(config.LOG_FILE_PATH, {
usePolling: true, // Enables polling to detect changes in all environments
interval: 1, // Poll every 100ms (you can adjust this if needed)
awaitWriteFinish: { // Wait for file to finish being written before triggering
stabilityThreshold: 1, // Time to wait before considering the file stable
stabilityThreshold: 10, // Time to wait before considering the file stable
pollInterval: 1, // Interval at which to poll for file stability
},
persistent: true, // Keeps watching the file even after initial change
Expand Down
33 changes: 14 additions & 19 deletions api/src/services/contentful.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { v4 as uuidv4 } from "uuid";
import _ from "lodash";
import axios from "axios";
import jsonpath from "jsonpath";
// import pLimit from 'p-limit';
import pLimit from 'p-limit';


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

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

// This code is intentionally commented out
// for testing purposes.

// const limit = pLimit(10); // Limit concurrent operations to 10
// const tasks = assets.map((asset: any) =>
// limit(() => saveAsset(asset, failedJSON, assetData, metadata, projectId, destination_stack_id, 0))
// );
// await Promise.all(tasks);

await Promise.all(tasks);
const assetMasterFolderPath = path.join(assetsSave, ASSETS_FAILED_FILE);

await writeOneFile(path.join(assetsSave, ASSETS_SCHEMA_FILE), assetData);
// This code is intentionally commented out

// const chunks: { [key: string]: any } = makeChunks(assetData);
// const refs: any = {};

Expand Down Expand Up @@ -653,12 +646,6 @@ const createEntry = async (packagePath: any, destination_stack_id:string, projec
entryData[name][locale][id][formattedKey] = value;
}
);
const message = getLogMessage(
srcFunc,
`Entry title "${entryData[name][locale][id]?.title}"(${name}) in the ${locale} locale has been successfully transformed.`,
{}
)
customLogger(projectId, destination_stack_id, 'info', message)
});
});

Expand All @@ -673,6 +660,14 @@ const createEntry = async (packagePath: any, destination_stack_id:string, projec
values as { [key: string]: any }
)) {
const chunks = await makeChunks(localeValues);
for (const [entryKey, entryValue] of Object.entries(localeValues)){
const message = getLogMessage(
srcFunc,
`Entry title "${(entryValue as { title: string })?.title}"(${key}) in the ${localeKey} locale has been successfully transformed.`,
{}
);
await customLogger(projectId, destination_stack_id, "info", message);
}
const refs: { [key: string]: any } = {};
let chunkIndex = 1;
const filePath = path.join(
Expand Down
2 changes: 2 additions & 0 deletions api/src/services/runCli.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export const runCli = async (rg: string, user_id: string, stack_uid: any, projec
!isTest && ProjectModelLowdb.update((data: any) => {
data.projects[projectIndex].isMigrationCompleted = true;
data.projects[projectIndex].isMigrationStarted = false;
data.projects[projectIndex].current_step = 5;
data.projects[projectIndex].status = 5;
})
}
});
Expand Down
18 changes: 18 additions & 0 deletions ui/src/components/ContentMapper/contentMapper.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export interface FieldMapType {
_canSelect?: boolean;
advanced?: Advanced;
contentstackUid: string;
_invalid?: boolean;
}

export interface Advanced {
Expand Down Expand Up @@ -174,4 +175,21 @@ export interface MappingObj {
options: Mapping;
}

export interface FieldHistoryObj {
[key: string]: ModifiedField[];
}

export interface FieldObj {
[key: string]: ModifiedField;
}

export interface ModifiedField {
at: number;
checked: boolean;
id: string;
otherCmsType: string;
parentId: string;
uid: string;
}


Loading