Skip to content

Commit

Permalink
fixed the issue of localised published
Browse files Browse the repository at this point in the history
  • Loading branch information
cs-raj committed Aug 5, 2024
1 parent 785ab6b commit 273f92a
Showing 1 changed file with 45 additions and 20 deletions.
65 changes: 45 additions & 20 deletions packages/contentstack-import/src/import/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
} from '../../utils';
import { ModuleClassParams } from '../../types';
import BaseClass, { ApiOptions } from './base-class';

export default class EntriesImport extends BaseClass {
private assetUidMapperPath: string;
private assetUidMapper: Record<string, any>;
Expand Down Expand Up @@ -68,11 +67,25 @@ export default class EntriesImport extends BaseClass {
this.entriesUIDMapperPath = path.join(sanitizePath(this.entriesMapperPath), 'uid-mapping.json');
this.uniqueUidMapperPath = path.join(sanitizePath(this.entriesMapperPath), 'unique-mapping.json');
this.modifiedCTsPath = path.join(sanitizePath(this.entriesMapperPath), 'modified-schemas.json');
this.marketplaceAppMapperPath = path.join(sanitizePath(this.importConfig.data), 'mapper', 'marketplace_apps', 'uid-mapping.json');
this.taxonomiesPath = path.join(sanitizePath(this.importConfig.data), 'mapper', 'taxonomies', 'terms', 'success.json');
this.marketplaceAppMapperPath = path.join(
sanitizePath(this.importConfig.data),
'mapper',
'marketplace_apps',
'uid-mapping.json',
);
this.taxonomiesPath = path.join(
sanitizePath(this.importConfig.data),
'mapper',
'taxonomies',
'terms',
'success.json',
);
this.entriesConfig = importConfig.modules.entries;
this.entriesPath = path.resolve(sanitizePath(importConfig.data), sanitizePath(this.entriesConfig.dirName));
this.cTsPath = path.resolve(sanitizePath(importConfig.data), sanitizePath(importConfig.modules['content-types'].dirName));
this.cTsPath = path.resolve(
sanitizePath(importConfig.data),
sanitizePath(importConfig.modules['content-types'].dirName),
);
this.localesPath = path.resolve(
sanitizePath(importConfig.data),
sanitizePath(importConfig.modules.locales.dirName),
Expand Down Expand Up @@ -898,23 +911,35 @@ export default class EntriesImport extends BaseClass {

if (chunk) {
let apiContent = values(chunk as Record<string, any>[]);
await this.makeConcurrentCall({
apiContent,
processName,
indexerCount,
currentIndexer: +index,
apiParams: {
reject: onReject,
resolve: onSuccess,
entity: 'publish-entries',
includeParamOnCompletion: true,
serializeData: this.serializePublishEntries.bind(this),
additionalInfo: { contentType, locale, cTUid },
},
concurrencyLimit: this.importConcurrency,
}).then(() => {
log(this.importConfig, `Published entries for content type ${cTUid} in locale ${locale}`, 'success');
let apiContentDuplicate: any = [];
apiContent.forEach((content: Record<string, any>) => {
content?.publish_details?.forEach((publish: Record<string, any>) => {
let c2 = { ...content };
c2.locale = publish.locale;
c2.publish_details = [publish];
apiContentDuplicate.push(c2);
});
});
for (let i = 0; i < apiContentDuplicate.length; i++) {
let apiContent = [apiContentDuplicate[i]];
await this.makeConcurrentCall({
apiContent,
processName,
indexerCount,
currentIndexer: +index,
apiParams: {
reject: onReject,
resolve: onSuccess,
entity: 'publish-entries',
includeParamOnCompletion: true,
serializeData: this.serializePublishEntries.bind(this),
additionalInfo: { contentType, locale: apiContentDuplicate[i]?.locale, cTUid },
},
concurrencyLimit: this.importConcurrency,
}).then(() => {
log(this.importConfig, `Published entries for content type ${cTUid} in locale ${locale}`, 'success');
});
}
}
}
}
Expand Down

0 comments on commit 273f92a

Please sign in to comment.