feat: update percentile

This commit is contained in:
Fine 2023-06-02 16:36:55 +08:00
parent 0db3c06770
commit 6555a1d5a6
3 changed files with 18 additions and 12 deletions

View File

@ -121,12 +121,23 @@ export function useExpressionsSourceProcessor(
const name = ((results[0] || {}).metric || {}).name; const name = ((results[0] || {}).metric || {}).name;
if (type === ExpressionResultType.TIME_SERIES_VALUES) { if (type === ExpressionResultType.TIME_SERIES_VALUES) {
source[c.label || name] = results[0].values.map((d: { value: unknown }) => d.value) || []; if (results.length === 1) {
return; source[c.label || name] = results[0].values.map((d: { value: unknown }) => d.value) || [];
} else {
const labels = (c.label || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, ""));
for (const item of results) {
const values = item.values.map((d: { value: unknown }) => Number(d.value)) || [];
const index = Number(item.metric.labels[0].value);
if (labels[index]) {
source[labels[index]] = values;
} else {
source[index] = values;
}
}
}
} }
if (type === ExpressionResultType.SINGLE_VALUE) { if (type === ExpressionResultType.SINGLE_VALUE) {
source[c.label || name] = results[0].values[0].value; source[c.label || name] = results[0].values[0].value;
return;
} }
if (([ExpressionResultType.RECORD_LIST, ExpressionResultType.SORTED_LIST] as string[]).includes(type)) { if (([ExpressionResultType.RECORD_LIST, ExpressionResultType.SORTED_LIST] as string[]).includes(type)) {
source[name] = results[0].values; source[name] = results[0].values;

View File

@ -178,7 +178,6 @@ export function useSourceProcessor(
return d; return d;
}); });
console.log(source);
} }
if (type === MetricQueryTypes.READHEATMAP) { if (type === MetricQueryTypes.READHEATMAP) {
const resVal = Object.values(resp.data)[0] || {}; const resVal = Object.values(resp.data)[0] || {};

View File

@ -56,7 +56,7 @@ limitations under the License. -->
" "
/> />
</div> </div>
<div class="item mb-10"> <div class="item mb-10" v-show="!isExpression">
<span class="label">{{ t("aggregation") }}</span> <span class="label">{{ t("aggregation") }}</span>
<SelectSingle <SelectSingle
:value="currentMetric.calculation" :value="currentMetric.calculation"
@ -131,13 +131,9 @@ limitations under the License. -->
); );
}); });
const isTopn = computed(() => const isTopn = computed(() =>
[ [ProtocolTypes.SortMetrics, ProtocolTypes.ReadSampledRecords, ProtocolTypes.ReadRecords].includes(
ProtocolTypes.SortMetrics, metricTypes.value[props.index],
ProtocolTypes.ReadSampledRecords, ),
ProtocolTypes.ReadRecords,
ExpressionResultType.SORTED_LIST,
ExpressionResultType.RECORD_LIST,
].includes(metricTypes.value[props.index]),
); );
function updateConfig(index: number, param: { [key: string]: string }) { function updateConfig(index: number, param: { [key: string]: string }) {
const key = Object.keys(param)[0]; const key = Object.keys(param)[0];