Skip to content

Commit

Permalink
Please code review
Browse files Browse the repository at this point in the history
  • Loading branch information
machadoum committed Sep 6, 2022
1 parent 7c9c0d3 commit 240fe73
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { useState, useEffect, useMemo, useRef } from 'react';
import { filter, head, noop, orderBy, pipe, get } from 'lodash/fp';
import { filter, head, noop, orderBy, pipe, has } from 'lodash/fp';
import type { MlSummaryJob } from '@kbn/ml-plugin/common';

import { DEFAULT_ANOMALY_SCORE } from '../../../../../common/constants';
Expand Down Expand Up @@ -160,7 +160,7 @@ function formatResultData(
return NOTABLE_ANOMALIES_IDS.map((notableJobId) => {
const job = findJobWithId(notableJobId)(notableAnomaliesJobs);
const bucket = buckets.find(({ key }) => key === job?.id);
const hasUserName = !!get("entity.hits.hits[0]._source['user.name']", bucket);
const hasUserName = has("entity.hits.hits[0]._source['user.name']", bucket);

return {
name: notableJobId,
Expand Down
58 changes: 5 additions & 53 deletions x-pack/plugins/security_solution/public/network/store/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { reducerWithInitialState } from 'typescript-fsa-reducers';
import { get } from 'lodash/fp';
import { get, set } from 'lodash/fp';
import {
Direction,
FlowTarget,
Expand Down Expand Up @@ -202,64 +202,16 @@ export const networkReducer = reducerWithInitialState(initialNetworkState)
}))
.case(updateNetworkAnomaliesJobIdFilter, (state, { jobIds, networkType }) => {
if (networkType === NetworkType.page) {
return {
...state,
page: {
...state.page,
queries: {
...state.page.queries,
anomalies: {
...state.page.queries.anomalies,
jobIdSelection: jobIds,
},
},
},
};
return set('page.queries.anomalies.jobIdSelection', jobIds, state);
} else {
return {
...state,
details: {
...state.details,
queries: {
...state.details.queries,
anomalies: {
...state.details.queries.anomalies,
jobIdSelection: jobIds,
},
},
},
};
return set('details.queries.anomalies.jobIdSelection', jobIds, state);
}
})
.case(updateNetworkAnomaliesInterval, (state, { interval, networkType }) => {
if (networkType === NetworkType.page) {
return {
...state,
page: {
...state.page,
queries: {
...state.page.queries,
anomalies: {
...state.page.queries.anomalies,
intervalSelection: interval,
},
},
},
};
return set('page.queries.anomalies.intervalSelection', interval, state);
} else {
return {
...state,
details: {
...state.details,
queries: {
...state.details.queries,
anomalies: {
...state.details.queries.anomalies,
intervalSelection: interval,
},
},
},
};
return set('details.queries.anomalies.intervalSelection', interval, state);
}
})
.build();
57 changes: 5 additions & 52 deletions x-pack/plugins/security_solution/public/users/store/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { reducerWithInitialState } from 'typescript-fsa-reducers';
import { set } from 'lodash/fp';
import { DEFAULT_TABLE_ACTIVE_PAGE, DEFAULT_TABLE_LIMIT } from '../../common/store/constants';

import {
Expand Down Expand Up @@ -136,64 +137,16 @@ export const usersReducer = reducerWithInitialState(initialUsersState)
}))
.case(updateUsersAnomaliesJobIdFilter, (state, { jobIds, usersType }) => {
if (usersType === 'page') {
return {
...state,
page: {
...state.page,
queries: {
...state.page.queries,
anomalies: {
...state.page.queries.anomalies,
jobIdSelection: jobIds,
},
},
},
};
return set('page.queries.anomalies.jobIdSelection', jobIds, state);
} else {
return {
...state,
details: {
...state.details,
queries: {
...state.details.queries,
anomalies: {
...state.details.queries.anomalies,
jobIdSelection: jobIds,
},
},
},
};
return set('details.queries.anomalies.jobIdSelection', jobIds, state);
}
})
.case(updateUsersAnomaliesInterval, (state, { interval, usersType }) => {
if (usersType === 'page') {
return {
...state,
page: {
...state.page,
queries: {
...state.page.queries,
anomalies: {
...state.page.queries.anomalies,
intervalSelection: interval,
},
},
},
};
return set('page.queries.anomalies.intervalSelection', interval, state);
} else {
return {
...state,
details: {
...state.details,
queries: {
...state.details.queries,
anomalies: {
...state.details.queries.anomalies,
intervalSelection: interval,
},
},
},
};
return set('details.queries.anomalies.intervalSelection', interval, state);
}
})
.build();

0 comments on commit 240fe73

Please sign in to comment.