Skip to content

Commit 107d2e6

Browse files
fix: copilot review 3
1 parent 91b1704 commit 107d2e6

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

src/utils/versions/__test__/sortVersions.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {sortVersions} from '../sortVersions';
22
import type {PreparedVersion} from '../types';
33

44
describe('sortVersions', () => {
5-
test('should sort versions by majorIndex in descending order', function () {
5+
test('should sort versions by majorIndex in ascending order', function () {
66
const versions: PreparedVersion[] = [
77
{version: 'v2.0.0', majorIndex: 1},
88
{version: 'v1.0.0', majorIndex: 2},
@@ -34,7 +34,7 @@ describe('sortVersions', () => {
3434
]);
3535
});
3636

37-
test('should sort versions by minorIndex in descending order when majorIndex is the same', function () {
37+
test('should sort versions by minorIndex in ascending order when majorIndex is the same', function () {
3838
const versions: PreparedVersion[] = [
3939
{version: 'v1.2.0', majorIndex: 2, minorIndex: 1},
4040
{version: 'v1.1.0', majorIndex: 2, minorIndex: 2},

src/utils/versions/clusterVersionColors.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type {MetaClusterVersion} from '../../types/api/meta';
22

3+
import {COLORS, DEFAULT_COLOR, getMinorVersionColorVariant, hashCode} from './getVersionsColors';
4+
import {getMinorVersion} from './parseVersion';
35
import {sortVersions} from './sortVersions';
46
import type {
57
ColorIndexToVersionsMap,
@@ -8,8 +10,6 @@ import type {
810
VersionsDataMap,
911
} from './types';
1012

11-
import {COLORS, DEFAULT_COLOR, getMinorVersion, getMinorVersionColorVariant, hashCode} from '.';
12-
1313
const UNDEFINED_COLOR_INDEX = '__no_color__';
1414

1515
export const getVersionMap = (
@@ -75,23 +75,24 @@ export const prepareClusterVersions = (
7575
filteredVersions.forEach((item) => {
7676
if (result[item.version]) {
7777
// Sum count for versions of different nodes types
78+
// Do not recalculate version data
7879
const currentCount = result[item.version].count || 0;
7980
const itemCount = item.count || 0;
8081

8182
result[item.version].count = currentCount + itemCount;
83+
} else {
84+
const minorVersion = getMinorVersion(item.version);
85+
const data = versionsDataMap.get(minorVersion);
86+
87+
result[item.version] = {
88+
version: item.version,
89+
minorVersion,
90+
color: data?.color,
91+
majorIndex: data?.majorIndex,
92+
minorIndex: data?.minorIndex,
93+
count: item.count || 0,
94+
};
8295
}
83-
84-
const minorVersion = getMinorVersion(item.version);
85-
const data = versionsDataMap.get(minorVersion);
86-
87-
result[item.version] = {
88-
version: item.version,
89-
minorVersion,
90-
color: data?.color,
91-
majorIndex: data?.majorIndex,
92-
minorIndex: data?.minorIndex,
93-
count: item.count || 0,
94-
};
9596
});
9697

9798
return sortVersions(Object.values(result));

0 commit comments

Comments
 (0)