Skip to content

Commit

Permalink
[Core] Indexation task only on request or library save (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmyb authored Aug 30, 2023
1 parent 542c70e commit e8d024e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions apps/core/src/domain/indexationManager/indexationManagerDomain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface IIndexDatabaseParams {
findRecordParams: IFindRecordParams | IFindRecordParams[];
attributes?: {up?: string[]; del?: string[]};
ctx: IQueryInfos;
forceNoTask?: boolean;
}

export interface IIndexationManagerDomain {
Expand Down Expand Up @@ -212,7 +213,8 @@ export default function ({
await _indexDatabase({
findRecordParams: {library: l.id, filters},
ctx,
attributes: {up: intersections.map(a => a.id)}
attributes: {up: intersections.map(a => a.id)},
forceNoTask: true
});
}
}
Expand Down Expand Up @@ -244,7 +246,8 @@ export default function ({
library: data.libraryId,
filters: [{field: 'id', condition: AttributeCondition.EQUAL, value: data.id}]
},
ctx
ctx,
forceNoTask: true
});

break;
Expand Down Expand Up @@ -285,7 +288,8 @@ export default function ({
filters: [{field: 'id', condition: AttributeCondition.EQUAL, value: data.recordId}]
},
ctx,
attributes: isActivated || !isAttrToIndex ? null : {up: [data.attributeId]}
attributes: isActivated || !isAttrToIndex ? null : {up: [data.attributeId]},
forceNoTask: true
});
}

Expand All @@ -309,7 +313,8 @@ export default function ({
filters: [{field: 'id', condition: AttributeCondition.EQUAL, value: data.recordId}]
},
ctx,
attributes: attrProps.multiple_values ? {up: [data.attributeId]} : {del: [data.attributeId]}
attributes: attrProps.multiple_values ? {up: [data.attributeId]} : {del: [data.attributeId]},
forceNoTask: true
});

// if the updated/deleted attribute is the label of the library
Expand Down Expand Up @@ -350,7 +355,7 @@ export default function ({
const _indexDatabase = async (params: IIndexDatabaseParams, task?: ITaskFuncParams): Promise<string> => {
const findRecordParams = [].concat(params.findRecordParams || []);

if (typeof task?.id === 'undefined') {
if (!params.forceNoTask && typeof task?.id === 'undefined') {
const newTaskId = uuidv4();

await tasksManagerDomain.createTask(
Expand Down

0 comments on commit e8d024e

Please sign in to comment.