Skip to content

Commit 6a837d5

Browse files
committed
Shorten math comparisons
1 parent aebb890 commit 6a837d5

File tree

1 file changed

+12
-36
lines changed
  • site/frontend/src/pages/detailed-query

1 file changed

+12
-36
lines changed

site/frontend/src/pages/detailed-query/page.vue

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -59,32 +59,22 @@ const tableData = computed(() => {
5959
aValue = a.timeSeconds;
6060
bValue = b.timeSeconds;
6161
// Use percentage change as secondary sort for equal absolute values
62-
aSecondary =
63-
a.timeDelta !== null ? Math.abs(a.timeDelta.percentage) : 0;
64-
bSecondary =
65-
b.timeDelta !== null ? Math.abs(b.timeDelta.percentage) : 0;
62+
aSecondary = Math.abs(a.timeDelta?.percentage ?? 0);
63+
bSecondary = Math.abs(b.timeDelta?.percentage ?? 0);
6664
break;
6765
case "executions": // Executions
6866
aValue = a.executions;
6967
bValue = b.executions;
7068
// Use percentage change as secondary sort for equal absolute values
71-
aSecondary =
72-
a.executionsDelta !== null
73-
? Math.abs(a.executionsDelta.percentage)
74-
: 0;
75-
bSecondary =
76-
b.executionsDelta !== null
77-
? Math.abs(b.executionsDelta.percentage)
78-
: 0;
69+
aSecondary = Math.abs(a.executionsDelta?.percentage ?? 0);
70+
bSecondary = Math.abs(b.executionsDelta?.percentage ?? 0);
7971
break;
8072
case "cacheHits": // Hits
8173
aValue = a.cacheHits;
8274
bValue = b.cacheHits;
8375
// Use percentage change as secondary sort for equal absolute values
84-
aSecondary =
85-
a.cacheHitsDelta !== null ? Math.abs(a.cacheHitsDelta.percentage) : 0;
86-
bSecondary =
87-
b.cacheHitsDelta !== null ? Math.abs(b.cacheHitsDelta.percentage) : 0;
76+
aSecondary = Math.abs(a.cacheHitsDelta?.percentage ?? 0);
77+
bSecondary = Math.abs(b.cacheHitsDelta?.percentage ?? 0);
8878
break;
8979
case "incrementalLoading": // Incremental loading (s)
9080
aValue = a.incrementalLoading;
@@ -118,23 +108,15 @@ const tableData = computed(() => {
118108
bValue =
119109
b.executionsDelta !== null ? b.executionsDelta.delta : -Infinity;
120110
// Use percentage as secondary sort for equal delta values
121-
aSecondary =
122-
a.executionsDelta !== null
123-
? Math.abs(a.executionsDelta.percentage)
124-
: 0;
125-
bSecondary =
126-
b.executionsDelta !== null
127-
? Math.abs(b.executionsDelta.percentage)
128-
: 0;
111+
aSecondary = Math.abs(a.executionsDelta?.percentage ?? 0);
112+
bSecondary = Math.abs(b.executionsDelta?.percentage ?? 0);
129113
break;
130114
case "cacheHitsDelta": // Cache hits delta
131115
aValue = a.cacheHitsDelta !== null ? a.cacheHitsDelta.delta : -Infinity;
132116
bValue = b.cacheHitsDelta !== null ? b.cacheHitsDelta.delta : -Infinity;
133117
// Use percentage as secondary sort for equal delta values
134-
aSecondary =
135-
a.cacheHitsDelta !== null ? Math.abs(a.cacheHitsDelta.percentage) : 0;
136-
bSecondary =
137-
b.cacheHitsDelta !== null ? Math.abs(b.cacheHitsDelta.percentage) : 0;
118+
aSecondary = Math.abs(a.cacheHitsDelta?.percentage ?? 0);
119+
bSecondary = Math.abs(b.cacheHitsDelta?.percentage ?? 0);
138120
break;
139121
case "incrementalLoadingDelta": // Incremental loading delta
140122
aValue =
@@ -146,14 +128,8 @@ const tableData = computed(() => {
146128
? b.incrementalLoadingDelta.delta
147129
: -Infinity;
148130
// Use percentage as secondary sort for equal delta values
149-
aSecondary =
150-
a.incrementalLoadingDelta !== null
151-
? Math.abs(a.incrementalLoadingDelta.percentage)
152-
: 0;
153-
bSecondary =
154-
b.incrementalLoadingDelta !== null
155-
? Math.abs(b.incrementalLoadingDelta.percentage)
156-
: 0;
131+
aSecondary = Math.abs(a.incrementalLoadingDelta?.percentage ?? 0);
132+
bSecondary = Math.abs(b.incrementalLoadingDelta?.percentage ?? 0);
157133
break;
158134
default:
159135
aValue = a.label;

0 commit comments

Comments
 (0)