Skip to content

Commit

Permalink
Fixes filtering bug when user selects 'Environment: Not defined'. Now
Browse files Browse the repository at this point in the history
filters properly by filtering for docs where service.environment does
not exist
  • Loading branch information
ogupte committed Jul 9, 2020
1 parent 7e1b4d7 commit 5dcd975
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
TRANSACTION_REQUEST,
TRANSACTION_PAGE_LOAD,
} from '../../../common/transaction_types';
import { ENVIRONMENT_NOT_DEFINED } from '../../../common/environment_filter_values';

interface Options {
setup: Setup & SetupTimeRange;
Expand All @@ -42,12 +43,23 @@ export async function getServiceMapServiceNodeInfo({
}: Options & { serviceName: string; environment?: string }) {
const { start, end } = setup;

const environmentNotDefinedFilter = {
bool: { must_not: [{ exists: { field: SERVICE_ENVIRONMENT } }] },
};

const filter: ESFilter[] = [
{ range: rangeFilter(start, end) },
{ term: { [SERVICE_NAME]: serviceName } },
...(environment ? [{ term: { [SERVICE_ENVIRONMENT]: environment } }] : []),
];

if (environment) {
filter.push(
environment === ENVIRONMENT_NOT_DEFINED
? environmentNotDefinedFilter
: { term: { [SERVICE_ENVIRONMENT]: environment } }
);
}

const minutes = Math.abs((end - start) / (1000 * 60));

const taskParams = {
Expand Down

0 comments on commit 5dcd975

Please sign in to comment.