Skip to content

Commit 07e5941

Browse files
committed
refactor: remove commented code & entries fetch optimization code
1 parent e9d6e7e commit 07e5941

File tree

2 files changed

+24
-39
lines changed

2 files changed

+24
-39
lines changed

packages/contentstack-export/src/export/modules/entries.ts

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -173,36 +173,31 @@ export default class EntriesExport extends BaseClass {
173173
async getTotalEntriesCount(entryRequestOptions: Array<Record<string, any>>): Promise<number> {
174174
log.debug('Calculating total entries count for progress tracking...', this.exportConfig.context);
175175

176-
let totalCount = 0;
177-
178-
try {
179-
for (const option of entryRequestOptions) {
180-
const countQuery = {
181-
locale: option.locale,
182-
limit: 1,
183-
include_count: true,
184-
query: { locale: option.locale },
185-
};
186-
187-
this.applyQueryFilters(countQuery, 'entries');
188-
189-
try {
190-
const response = await this.stackAPIClient.contentType(option.contentType).entry().query(countQuery).find();
191-
192-
const count = response.count || 0;
193-
totalCount += count;
194-
log.debug(
195-
`Content type ${option.contentType} (${option.locale}): ${count} entries`,
196-
this.exportConfig.context,
197-
);
198-
} catch (error) {
199-
log.debug(`Failed to get count for ${option.contentType}:${option.locale}`, this.exportConfig.context);
200-
}
176+
const countPromises = entryRequestOptions.map(async (option) => {
177+
const countQuery = {
178+
locale: option.locale,
179+
limit: 1,
180+
include_count: true,
181+
query: { locale: option.locale },
182+
};
183+
184+
this.applyQueryFilters(countQuery, 'entries');
185+
186+
try {
187+
const response = await this.stackAPIClient.contentType(option.contentType).entry().query(countQuery).find();
188+
const count = response.count || 0;
189+
log.debug(`Content type ${option.contentType} (${option.locale}): ${count} entries`, this.exportConfig.context);
190+
return count;
191+
} catch (error) {
192+
log.debug(`Failed to get count for ${option.contentType}:${option.locale}`, this.exportConfig.context);
193+
return 0;
201194
}
202-
} catch (error) {
203-
log.debug('Error calculating total entries count, using collection count as fallback', this.exportConfig.context);
204-
return entryRequestOptions.length;
205-
}
195+
});
196+
197+
const results = await Promise.allSettled(countPromises);
198+
const totalCount = results.reduce((sum, result) => {
199+
return sum + (result.status === 'fulfilled' ? result.value : 0);
200+
}, 0);
206201

207202
log.debug(`Total entries count: ${totalCount}`, this.exportConfig.context);
208203
return totalCount;

packages/contentstack-import/src/import/modules/environments.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,6 @@ export default class ImportEnvironments extends BaseClass {
5555
await this.importEnvironments();
5656

5757
await this.processImportResults();
58-
59-
// const progressFailures = this.progressManager?.getFailureCount() ?? 0;
60-
// const hasFailures = progressFailures > 0;
61-
// this.completeProgress(!hasFailures);
62-
63-
// if (hasFailures) {
64-
// log.warn(`Environments import completed with ${progressFailures} failures`, this.importConfig.context);
65-
// } else {
66-
// log.success('Environments have been imported successfully!', this.importConfig.context);
67-
// }
6858
this.completeProgress(true);
6959
log.success('Environments have been imported successfully!', this.importConfig.context);
7060
} catch (error) {

0 commit comments

Comments
 (0)