Skip to content

Commit

Permalink
[backend] Fix migration for old platforms with nested IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelHassine committed Jan 29, 2025
1 parent 3fbff92 commit c9d9e3b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion opencti-platform/opencti-graphql/src/database/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,6 @@ export const elFindByIds = async (context, user, ids, opts = {}) => {
logApp.debug('[SEARCH] elInternalLoadById', { query });
const searchType = `${ids} (${types ? types.join(', ') : 'Any'})`;
const data = await elRawSearch(context, user, searchType, query).catch((err) => {
logApp.error(JSON.stringify(query));
throw DatabaseError('Find direct ids fail', { cause: err, query });
});
const elements = data.hits.hits;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const up = async (next) => {
const threat = threats[i];
const relatedToIds = threat[relKeyRelatedTo] ?? [];
const newIds = [];
const groupIds = R.splitEvery(5000, relatedToIds.filter((id) => isNotEmptyField(id)));
const groupIds = R.splitEvery(5000, relatedToIds.flat(Infinity).filter((id) => isNotEmptyField(id)));
for (let index = 0; index < groupIds.length; index += 1) {
const workingIds = groupIds[index];
const entitiesBaseData = await elFindByIds(context, SYSTEM_USER, workingIds, { baseData: true });
Expand Down Expand Up @@ -95,7 +95,7 @@ export const up = async (next) => {
const location = locations[i];
const locatedAtIds = location[relKeyLocatedAt] ?? [];
const newIds = [];
const groupIds = R.splitEvery(5000, locatedAtIds.filter((id) => isNotEmptyField(id)));
const groupIds = R.splitEvery(5000, locatedAtIds.flat(Infinity).filter((id) => isNotEmptyField(id)));
for (let index = 0; index < groupIds.length; index += 1) {
const workingIds = groupIds[index];
const entitiesBaseData = await elFindByIds(context, SYSTEM_USER, workingIds, { baseData: true });
Expand Down

0 comments on commit c9d9e3b

Please sign in to comment.