Skip to content

Commit

Permalink
7085 ixstatus revamp revisited (#7385)
Browse files Browse the repository at this point in the history
* WIP, fixtures rework for ix filters and aggregations

* Begun flattening aggregations response

* Flattened the Aggregations return

* Complete refactor to aggregation results

* Removed unused variables

* Removed unnecessary code

* Renamed as _deprecated previous factory implementation

* Moved ixSuggestions factory to Factory

* Changed filtering logic.

* Fixed Route validation and tests

* Using updated component

* removed accuracy from the filters untill the backend returns it

* Changed labeled and match to be optional

* Removed optional parameters from factory

* Changed logic to remove labeled and match if error or obsolete.

* Disabled eslint to be able to look at code

* Changed logic to ensure undefined values are not counted towards limits.

* Improved the conditions.

* showing error and obsolete in the statuses

* changed filters structure

* updated translations

* Added logic for processing to refelct obsolete

* Replaced text to show new logic

* Fixed tests to reflect new logic

* Added condition for null to be excluded.

* Reinstated document implementation

---------

Co-authored-by: Daneryl <daneryl@gmail.com>
Co-authored-by: A happy cat <acasadotorres@gmail.com>
Co-authored-by: Alberto Casado Torres <konzz@users.noreply.github.com>
  • Loading branch information
4 people authored Oct 18, 2024
1 parent 0250e45 commit e1ef2be
Show file tree
Hide file tree
Showing 29 changed files with 482 additions and 747 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -759,12 +759,12 @@ describe('InformationExtraction', () => {
status: 'processing',
state: {
labeled: true,
match: null,
withValue: true,
withSuggestion: true,
match: false,
hasContext: true,
processing: true,
obsolete: false,
obsolete: true,
error: false,
},
})
Expand Down Expand Up @@ -1011,9 +1011,9 @@ describe('InformationExtraction', () => {
error: 'Issue calculation suggestion',
state: {
labeled: true,
match: null,
withValue: true,
withSuggestion: false,
match: false,
hasContext: false,
processing: false,
obsolete: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ const fixtures: DBFixture = {
fixtureFactory.ixExtractor('fungusKindExtractor', 'kind', ['fungusTemplate']),
],
ixsuggestions: [
fixtureFactory.ixSuggestion(
fixtureFactory.ixSuggestion_deprecated(
'sh1_en',
'existingExtractor',
'shared1',
'animalTemplate',
'F3',
'kind'
),
fixtureFactory.ixSuggestion(
fixtureFactory.ixSuggestion_deprecated(
'sh1_es',
'existingExtractor',
'shared1',
Expand All @@ -110,23 +110,23 @@ const fixtures: DBFixture = {
'kind',
{ language: 'es' }
),
fixtureFactory.ixSuggestion(
fixtureFactory.ixSuggestion_deprecated(
'sh3_en',
'existingExtractor',
'shared3',
'plantTemplate',
'F5',
'kind'
),
fixtureFactory.ixSuggestion(
fixtureFactory.ixSuggestion_deprecated(
'sh4_en',
'fungusKindExtractor',
'shared4',
'fungusTemplate',
'F7',
'kind'
),
fixtureFactory.ixSuggestion(
fixtureFactory.ixSuggestion_deprecated(
'sh4_es',
'fungusKindExtractor',
'shared4',
Expand Down
47 changes: 12 additions & 35 deletions app/api/suggestions/pipelineStages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,23 @@ export const baseQueryFragment = (extractorId: ObjectId, ignoreProcessing = true
};

export const filterFragments = {
labeled: {
_fragment: { 'state.labeled': true },
match: { 'state.labeled': true, 'state.match': true },
mismatch: { 'state.labeled': true, 'state.match': false },
},
nonLabeled: {
_fragment: { 'state.labeled': false },
withSuggestion: { 'state.labeled': false, 'state.withSuggestion': true },
noSuggestion: { 'state.labeled': false, 'state.withSuggestion': false },
noContext: { 'state.labeled': false, 'state.hasContext': false },
obsolete: { 'state.labeled': false, 'state.obsolete': true },
others: { 'state.labeled': false, 'state.error': true },
},
labeled: { 'state.labeled': true },
nonLabeled: { 'state.labeled': false },
match: { 'state.match': true },
mismatch: { 'state.match': false },
obsolete: { 'state.obsolete': true },
error: { 'state.error': true },
};

export const translateCustomFilter = (customFilter: SuggestionCustomFilter) => {
const orFilters = [];
if (customFilter.labeled.match) {
orFilters.push(filterFragments.labeled.match);
}
if (customFilter.labeled.mismatch) {
orFilters.push(filterFragments.labeled.mismatch);
}

if (customFilter.nonLabeled.withSuggestion) {
orFilters.push(filterFragments.nonLabeled.withSuggestion);
}
if (customFilter.labeled) orFilters.push(filterFragments.labeled);
if (customFilter.nonLabeled) orFilters.push(filterFragments.nonLabeled);
if (customFilter.match) orFilters.push(filterFragments.match);
if (customFilter.mismatch) orFilters.push(filterFragments.mismatch);
if (customFilter.obsolete) orFilters.push(filterFragments.obsolete);
if (customFilter.error) orFilters.push(filterFragments.error);

if (customFilter.nonLabeled.noSuggestion) {
orFilters.push(filterFragments.nonLabeled.noSuggestion);
}
if (customFilter.nonLabeled.noContext) {
orFilters.push(filterFragments.nonLabeled.noContext);
}
if (customFilter.nonLabeled.obsolete) {
orFilters.push(filterFragments.nonLabeled.obsolete);
}
if (customFilter.nonLabeled.others) {
orFilters.push(filterFragments.nonLabeled.others);
}
return orFilters;
};

Expand Down
Loading

0 comments on commit e1ef2be

Please sign in to comment.