Skip to content

Commit

Permalink
[backend] remove code for empty dates (#6517)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archidoit committed Apr 15, 2024
1 parent 1a01d63 commit 3a31d6f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 75 deletions.
32 changes: 0 additions & 32 deletions opencti-platform/opencti-graphql/src/database/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1746,24 +1746,6 @@ const buildLocalMustFilter = async (validFilter) => {
}
};
}
} else if (filterDefinition?.type === 'date') { // date filters: nil <-> (field doesn't exist) OR (date <= epoch) OR (date >= 5138)
valueFiltering = {
bool: {
should: [{
bool: {
must_not: {
exists: {
field: R.head(arrayKeys)
}
}
}
},
{ range: { [R.head(arrayKeys)]: { lte: '1970-01-01T01:00:00.000Z' } } },
{ range: { [R.head(arrayKeys)]: { gte: '5138-11-16T09:46:40.000Z' } } }
],
minimum_should_match: 1,
}
};
}
valuesFiltering.push(valueFiltering);
}
Expand Down Expand Up @@ -1809,20 +1791,6 @@ const buildLocalMustFilter = async (validFilter) => {
}
};
}
} else if (filterDefinition?.type === 'date') { // date filters: not_nil <-> (field exists) AND (date > epoch) AND (date < 5138)
valueFiltering = {
bool: {
should: [{
exists: {
field: R.head(arrayKeys)
}
},
{ range: { [R.head(arrayKeys)]: { gt: '1970-01-01T01:00:00.000Z' } } },
{ range: { [R.head(arrayKeys)]: { lt: '5138-11-16T09:46:40.000Z' } } }
],
minimum_should_match: 3,
}
};
}
valuesFiltering.push(valueFiltering);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,49 +750,6 @@ describe('Complex filters combinations for elastic queries', () => {
expect(queryResult.data.reports.edges.map((n) => n.node.name).includes('Report1')).toBeTruthy();
expect(queryResult.data.reports.edges.map((n) => n.node.name).includes('Report2')).toBeTruthy();
});
it('should list entities according to filters: \'nil\' / \'not_nil\' operators on dates', async () => {
// publication date is empty
let queryResult = await queryAsAdmin({
query: REPORT_LIST_QUERY,
variables: {
first: 10,
filters: {
mode: 'and',
filters: [
{
key: 'published',
operator: 'nil',
values: [],
mode: 'or',
}
],
filterGroups: [],
},
}
});
expect(queryResult.data.reports.edges.length).toEqual(1);
expect(queryResult.data.reports.edges.map((n) => n.node.name).includes('Report3')).toBeTruthy();
// description is not empty
queryResult = await queryAsAdmin({
query: REPORT_LIST_QUERY,
variables: {
first: 10,
filters: {
mode: 'and',
filters: [
{
key: 'published',
operator: 'not_nil',
values: [],
mode: 'or',
}
],
filterGroups: [],
},
}
});
expect(queryResult.data.reports.edges.length).toEqual(4);
});
it('should list entities according to filters: aggregation with filters', async () => {
// count the number of entities with each marking
const distributionArgs = {
Expand Down

0 comments on commit 3a31d6f

Please sign in to comment.