From 7a95028272dac0704cef0cd5a3662e67b03df8e0 Mon Sep 17 00:00:00 2001 From: Maina Wycliffe Date: Fri, 4 Oct 2024 11:51:32 +0300 Subject: [PATCH] fix: fix config relationship table crashing due to change in API --- .../Configs/ConfigList/ConfigListColumn.tsx | 52 +------------------ 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/src/components/Configs/ConfigList/ConfigListColumn.tsx b/src/components/Configs/ConfigList/ConfigListColumn.tsx index 75f543b8b..e4bd520e2 100644 --- a/src/components/Configs/ConfigList/ConfigListColumn.tsx +++ b/src/components/Configs/ConfigList/ConfigListColumn.tsx @@ -1,11 +1,10 @@ import { Status } from "@flanksource-ui/components/Status"; import { Badge } from "@flanksource-ui/ui/Badge/Badge"; import ChangeCountIcon from "@flanksource-ui/ui/Icons/ChangeCount"; -import { CellContext, ColumnDef, Row } from "@tanstack/react-table"; +import { CellContext, ColumnDef } from "@tanstack/react-table"; import React from "react"; import { FaTrash } from "react-icons/fa"; import { IoChevronDown, IoChevronForward } from "react-icons/io5"; -import { ConfigAnalysisTypeItem } from "../../../api/services/configs"; import { ConfigItem } from "../../../api/types/configs"; import { TIME_BUCKETS, getTimeBucket } from "../../../utils/date"; import ConfigsTypeIcon from "../ConfigsTypeIcon"; @@ -97,7 +96,6 @@ export const configListColumns: ColumnDef[] = [ id: "changes", cell: React.memo(ConfigListChangeCell), enableGrouping: true, - aggregationFn: changeAggregationFN, aggregatedCell: ({ getValue }: CellContext) => { const value = getValue(); return ; @@ -123,7 +121,6 @@ export const configListColumns: ColumnDef[] = [ header: "Analysis", accessorKey: "analysis", cell: ConfigSummaryAnalysisCell, - aggregationFn: analysisAggregationFN, aggregatedCell: ConfigSummaryAnalysisCell, minSize: 50, maxSize: 100 @@ -197,53 +194,6 @@ export const configListColumns: ColumnDef[] = [ } ]; -function changeAggregationFN( - columnId: string, - leafRows: Row[], - childRows: Row[] -) { - let sum = 0; - leafRows?.forEach((row) => { - const values = row.getValue<{ total: number }[]>(columnId); - if (values) { - sum += values.reduce((acc, val) => acc + val.total, 0); - } - }); - return sum; -} - -function analysisAggregationFN( - columnId: string, - leafRows: Row[], - childRows: Row[] -) { - const result: Record< - string, - { - count: number; - data: ConfigAnalysisTypeItem; - } - > = {}; - leafRows?.forEach((row) => { - const values = row.getValue(columnId) || []; - values.forEach((value) => { - result[value.analysis_type] = result[value.analysis_type] ?? { - count: 0, - data: value - }; - result[value.analysis_type].count += 1; - }); - }); - const data = Object.keys(result).map((key) => { - return { - type: key, - count: result[key].count, - analysis: result[key].data - }; - }); - return data; -} - function changeColumnAccessorFN(row: any) { return getTimeBucket(row.updated_at); }