Skip to content

Commit

Permalink
fixes typo in test file, removes redundant delete signals call in int…
Browse files Browse the repository at this point in the history
…egration test, fixes logic for possibility of receving a null value in sort ids, removes unused utility function for checking valid sort ids
  • Loading branch information
dhurley14 committed Apr 20, 2021
1 parent 8aad3e1 commit d29c16f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('create_signals', () => {
});
});

test('it builds a now-5m up to today filter with timestsampOverride', () => {
test('it builds a now-5m up to today filter with timestampOverride', () => {
const query = buildEventsSearchQuery({
index: ['auditbeat-*'],
from: 'now-5m',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,7 @@ export const buildEventsSearchQuery = ({
},
};

if (
searchAfterSortIds != null &&
!isEmpty(searchAfterSortIds) &&
searchAfterSortIds.filter((sortId) => !isEmpty(sortId?.toString())).length > 0
) {
if (searchAfterSortIds != null && !isEmpty(searchAfterSortIds)) {
return {
...searchQuery,
body: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -848,10 +848,6 @@ export const isThreatParams = (params: RuleParams): params is ThreatRuleParams =
export const isMachineLearningParams = (params: RuleParams): params is MachineLearningRuleParams =>
params.type === 'machine_learning';

export const hasSafeSortIds = (sortIds: SortResults) => {
return sortIds?.every((sortId) => sortId != null && sortId < Number.MAX_SAFE_INTEGER);
};

/**
* Prevent javascript from returning Number.MAX_SAFE_INTEGER when Elasticsearch expects
* Java's Long.MAX_VALUE. This happens when sorting fields by date which are
Expand All @@ -865,7 +861,9 @@ export const hasSafeSortIds = (sortIds: SortResults) => {
*/
export const getSafeSortIds = (sortIds: SortResults | undefined) => {
return sortIds?.map((sortId) => {
if (sortId != null && sortId >= Number.MAX_SAFE_INTEGER) {
// haven't determined when we would receive a null value for a sort id
// but in case we do, default to sending the stringified Java max_int
if (sortId == null || sortId >= Number.MAX_SAFE_INTEGER) {
return '9223372036854775807';
}
return sortId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,6 @@ export default ({ getService }: FtrProviderContext) => {
const signals = signalsResponse.hits.hits.map((hit) => hit._source);

expect(signals.length).equal(200);
await deleteSignalsIndex(supertest);
});
});

Expand Down

0 comments on commit d29c16f

Please sign in to comment.