Skip to content

Commit

Permalink
fix: quota zero as default
Browse files Browse the repository at this point in the history
  • Loading branch information
jacovinus committed Dec 21, 2023
1 parent 4039a65 commit 8e5f3c9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/main/plugins/Cardinality/SeriesRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const SeriesRow: React.FC<SeriesRowProps> = ({
theme,
onFilter,
source,
quota = 4,
quota,
}) => {
const { handleDelete } = useCardinalityRequest();
const { isLoading } = useCardinalityStore();
Expand Down
14 changes: 10 additions & 4 deletions packages/main/plugins/Cardinality/api/useCardinalityData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,26 @@ export const useCardinalityData = (historyManager?, setHistoryItem?) => {
diff: query.diff || 0,
prev: query.valuePrev || 0,
share: calcPercent(query.value, data?.totalSeries) || 0,
quota: data.quota,
source: key,
onFilter,
}));
};

const formattedSeries = (data: CardinalityResponse) => {
const formattedSeries = (data: CardinalityResponse["data"]) => {
if (data) {
const keys = Object.keys(data);
let dataFormatted: CardinalityResponse["data"] = data;
if (!dataFormatted?.quota) {
dataFormatted.quota = 0;
}
const keys = Object.keys(dataFormatted);
const filteredKeys = keys.filter((f: any) =>
Array.isArray(data[f])
Array.isArray(dataFormatted[f])
);
const mappedKeys = filteredKeys.map((key: string) => ({
[key]: mapSeries(data[key], data, key),
[key]: mapSeries(dataFormatted[key], dataFormatted, key),
}));

return mappedKeys;
}
return [];
Expand Down
2 changes: 2 additions & 0 deletions packages/main/plugins/Cardinality/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,5 +346,7 @@ export function calcQuotaOverCardinality(cardinality: number, quota: number) {
}

export function isQuotaWarning(quotaOverCardinality: number) {

if(quotaOverCardinality === Infinity) return false
return quotaOverCardinality > 60;
}
1 change: 1 addition & 0 deletions packages/main/plugins/Cardinality/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface CardinalityData {
seriesCountByFocusLabelValue: SeriesCountByLabelName[];
seriesCountByLabelValuePair: SeriesCountByLabelName[];
labelValueCountByLabelName: SeriesCountByLabelName[];
quota?:number;
}
export interface CardinalityResponse {
data: CardinalityData;
Expand Down

0 comments on commit 8e5f3c9

Please sign in to comment.