Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix import entities with relationships
Browse files Browse the repository at this point in the history
Joao-vi committed Dec 16, 2024
1 parent 03203ea commit e71a2a1
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions app/api/csv/importEntity.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint-disable no-await-in-loop */
/* eslint-disable no-unreachable-loop */
/* eslint-disable no-restricted-syntax */
// eslint-disable-next-line node/no-restricted-import
import { createReadStream } from 'fs';
import entities from 'api/entities';
import { search } from 'api/search';
import entitiesModel from 'api/entities/entitiesModel';
import { processDocument } from 'api/files/processDocument';
import { RawEntity } from 'api/csv/entityRow';
import { TemplateSchema } from 'shared/types/templateType';
@@ -177,33 +179,31 @@ const translateEntity = async (
indexedTranslations: FullyIndexedTranslations,
dateFormat?: string
) => {
await entitiesModel.saveMultiple(
await Promise.all(
translations.map(async translatedEntity => {
const translatedEntityObject = await entityObject(
{
...translatedEntity,
propertiesFromColumns: {
...translatedEntity.propertiesFromColumns,
id: ensure(entity.sharedId),
},
},
template,
{
language: translatedEntity.language,
dateFormat,
}
);
for (const translatedEntity of translations) {
const entityParsed = await entityObject(
{
...translatedEntity,
propertiesFromColumns: {
...translatedEntity.propertiesFromColumns,
id: ensure(entity.sharedId),
},
},
template,
{
language: translatedEntity.language,
dateFormat,
}
);

return translateSelectLabels(
translatedEntityObject,
translatedEntity.language,
indexedTranslations,
propNameToThesauriId
);
})
)
);
const toSave = translateSelectLabels(
entityParsed,
translatedEntity.language,
indexedTranslations,
propNameToThesauriId
);

await entities.save(toSave, { language: translatedEntity.language, user: {} });
}

await Promise.all(
translations.map(async translatedEntity => {

0 comments on commit e71a2a1

Please sign in to comment.