Skip to content

Commit

Permalink
Added match settings for manual procedures
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaPolit committed Dec 11, 2024
1 parent 49ee174 commit aaf92c3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
22 changes: 21 additions & 1 deletion app/api/suggestions/specs/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ const fixtures: DBFixture = {
date: 5,
page: 2,
status: 'ready',
state: {
labeled: true,
obsolete: false,
match: true,
withValue: false,
withSuggestion: false,
processing: false,
error: false,
hasContext: false,
},
error: '',
},
{
Expand All @@ -130,6 +140,16 @@ const fixtures: DBFixture = {
date: 5,
page: 2,
status: 'ready',
state: {
labeled: true,
obsolete: false,
match: false,
withValue: false,
withSuggestion: false,
processing: false,
error: false,
hasContext: false,
},
error: '',
},
{
Expand Down Expand Up @@ -1323,9 +1343,9 @@ const stateFilterFixtures: DBFixture = {
factory.ixSuggestion({
extractorId: factory.id('unused_extractor'),
state: {
labeled: true,
match: true,
obsolete: true,
labeled: true,
error: true,
},
}),
Expand Down
8 changes: 5 additions & 3 deletions app/api/suggestions/specs/suggestions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ describe('suggestions', () => {
const query = { entityId: 'shared1' };
await Suggestions.setObsolete(query);
const obsoletes = await db.mongodb?.collection('ixsuggestions').find(query).toArray();
expect(obsoletes?.every(s => s.state.obsolete)).toBe(true);
expect(obsoletes?.every(s => s.state.obsolete && s.state.match === null)).toBe(true);
expect(obsoletes?.length).toBe(4);
});
});
Expand All @@ -1555,7 +1555,7 @@ describe('suggestions', () => {
const query = { entityId: 'shared1' };
await Suggestions.markSuggestionsWithoutSegmentation(query);
const notSegmented = await db.mongodb?.collection('ixsuggestions').find(query).toArray();
expect(notSegmented?.every(s => s.state.error)).toBe(true);
expect(notSegmented?.every(s => s.state.error && s.state.match === null)).toBe(true);
});

it('should not mark suggestions when segmentations are correct', async () => {
Expand All @@ -1572,7 +1572,7 @@ describe('suggestions', () => {
expect(segmented?.length).toBe(1);
expect(segmented?.every(s => s.state?.error)).toBe(false);
expect(notSegmented?.length).toBe(1);
expect(notSegmented?.every(s => s.state.error)).toBe(true);
expect(notSegmented?.every(s => s.state.error && s.state.match === null)).toBe(true);
});
});

Expand Down Expand Up @@ -1612,13 +1612,15 @@ describe('suggestions', () => {
...newErroringSuggestion,
state: {
error: true,
match: null,
},
});
expect(await findOneSuggestion({ entityId: newProcessingSuggestion.entityId })).toMatchObject(
{
...newProcessingSuggestion,
state: {
processing: true,
match: null,
},
}
);
Expand Down
6 changes: 4 additions & 2 deletions app/api/suggestions/suggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ const Suggestions = {
updateStates,

setObsolete: async (query: any) =>
IXSuggestionsModel.updateMany(query, { $set: { 'state.obsolete': true } }),
IXSuggestionsModel.updateMany(query, {
$set: { 'state.obsolete': true, 'state.match': null },
}),

markSuggestionsWithoutSegmentation: async (query: any) => {
const segmentedFilesIds = await getSegmentedFilesIds();
Expand All @@ -286,7 +288,7 @@ const Suggestions = {
...query,
fileId: { $nin: segmentedFilesIds },
},
{ $set: { 'state.error': true } }
{ $set: { 'state.error': true, 'state.match': null } }
);
},

Expand Down

0 comments on commit aaf92c3

Please sign in to comment.