Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Import only lodash submodules #2041

Merged
merged 6 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import _ from 'lodash';
import _flatten from 'lodash/flatten';
import _uniq from 'lodash/uniq';
import { Trace } from '../../../types/trace';
import { ITableSpan } from './types';

const serviceName = 'Service Name';
const operationName = 'Operation Name';

/**
* Used to get the values if no tag is picked from the first dropdown.
* Used to get the values if tag is picked from the first dropdown.
*/
function getValueTagIsPicked(tableValue: ITableSpan[], trace: Trace, nameSelectorTitle: string) {
const allSpans = trace.spans;
let availableTags = [];
let spansWithFilterTag = [];

// add all Spans with this tag key

Expand All @@ -33,32 +34,26 @@ function getValueTagIsPicked(tableValue: ITableSpan[], trace: Trace, nameSelecto
for (let j = 0; j < allSpans.length; j++) {
for (let l = 0; l < allSpans[j].tags.length; l++) {
if (nameSelectorTitle === allSpans[j].tags[l].key) {
availableTags.push(allSpans[j]);
spansWithFilterTag.push(allSpans[j]);
}
}
}
}
}
availableTags = [...new Set(availableTags)];
spansWithFilterTag = _uniq(spansWithFilterTag);

const tags = _(availableTags).map('tags').flatten().value();
let tagKeys = _(tags).map('key').uniq().value();
tagKeys = _.filter(tagKeys, function calc(o) {
return o !== nameSelectorTitle;
});
availableTags = [];
availableTags.push(serviceName);
availableTags.push(operationName);
availableTags = availableTags.concat(tagKeys);
const tags = spansWithFilterTag.map(o => o.tags);
let tagKeys = _uniq(_flatten(tags).map(o => o.key));
tagKeys = tagKeys.filter(o => o !== nameSelectorTitle);

return availableTags;
return [serviceName, operationName, ...tagKeys];
}

/**
* Used to get the values if no tag is picked from the first dropdown.
*/
function getValueNoTagIsPicked(trace: Trace, nameSelectorTitle: string) {
let availableTags = [];
const availableTags = [];
const allSpans = trace.spans;
if (nameSelectorTitle === serviceName) {
availableTags.push(operationName);
Expand All @@ -70,16 +65,14 @@ function getValueNoTagIsPicked(trace: Trace, nameSelectorTitle: string) {
availableTags.push(allSpans[i].tags[j].key);
}
}
availableTags = [...new Set(availableTags)];

return availableTags;
return _uniq(availableTags);
}

export function generateDropdownValue(trace: Trace) {
const allSpans = trace.spans;
const tags = _(allSpans).map('tags').flatten().value();
const tagKeys = _(tags).map('key').uniq().value();
const values = _.concat(serviceName, operationName, tagKeys);
const tags = _flatten(allSpans.map(o => o.tags));
const tagKeys = _uniq(tags.map(o => o.key));
const values = [serviceName, operationName, ...tagKeys];
return values;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import memoizeOne from 'memoize-one';
import * as _ from 'lodash';
import _uniq from 'lodash/uniq';
import DRange from 'drange';
import { Trace, Span } from '../../../types/trace';
import { ITableSpan } from './types';
Expand Down Expand Up @@ -115,23 +115,9 @@ function valueFirstDropdown(selectedTagKey: string, trace: Trace) {
const allSpans = trace.spans;
// all possibilities that can be displayed
if (selectedTagKey === serviceName) {
const temp = _.chain(allSpans)
.groupBy(x => x.process.serviceName)
.map((value, key) => ({ key }))
.uniq()
.value();
for (let i = 0; i < temp.length; i++) {
allDiffColumnValues.push(temp[i].key);
}
allDiffColumnValues = _uniq(allSpans.map(x => x.process.serviceName));
} else if (selectedTagKey === operationName) {
const temp = _.chain(allSpans)
.groupBy(x => x.operationName)
.map((value, key) => ({ key }))
.uniq()
.value();
for (let i = 0; i < temp.length; i++) {
allDiffColumnValues.push(temp[i].key);
}
allDiffColumnValues = _uniq(allSpans.map(x => x.operationName));
} else {
for (let i = 0; i < allSpans.length; i++) {
for (let j = 0; j < allSpans[i].tags.length; j++) {
Expand All @@ -140,7 +126,7 @@ function valueFirstDropdown(selectedTagKey: string, trace: Trace) {
}
}
}
allDiffColumnValues = [...new Set(allDiffColumnValues)];
allDiffColumnValues = _uniq(allDiffColumnValues);
}
// used to build the table
const allTableValues = [];
Expand Down Expand Up @@ -450,7 +436,7 @@ function valueSecondDropdown(
let newColumnValues = [] as any;
// if second dropdown is no tag
if (selectedTagKeySecond === serviceName || selectedTagKeySecond === operationName) {
diffNamesA = [...new Set(diffNamesA)];
diffNamesA = _uniq(diffNamesA);
newColumnValues = buildDetail(
diffNamesA,
tempArray,
Expand All @@ -470,7 +456,7 @@ function valueSecondDropdown(
}
}
}
diffNamesA = [...new Set(diffNamesA)];
diffNamesA = _uniq(diffNamesA);
newColumnValues = buildDetail(
diffNamesA,
tempArray,
Expand Down
Loading