Skip to content

Commit

Permalink
Merge pull request #1456 from flanksource/1428-incorrect-count-insigh…
Browse files Browse the repository at this point in the history
…t-inside-topology-insights-count

fix: fix incorrect count for topology insight
  • Loading branch information
moshloop authored Oct 24, 2023
2 parents 1eef6e5 + d7a7180 commit c556673
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/api/query-hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,9 @@ export function useGetTopologyRelatedInsightsQuery(
select: (response) => {
return {
...response,
data: response?.data?.flatMap((item) => item.config?.analysis)
data: response?.data?.map((item) =>
item.config.analysis.find((a) => a.id === item.analysis_id)
)
};
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/api/services/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ export const getTopologyRelatedInsights = async (
return resolve(
ConfigDB.get<
| {
analysis_id: string;
config: {
id: string;
name: string;
Expand All @@ -429,12 +430,12 @@ export const getTopologyRelatedInsights = async (
| "sanitizedMessageHTML"
| "first_observed"
| "message"
>;
>[];
};
}[]
| null
>(
`/analysis_by_component?component_id=eq.${id}${paginationQueryParams}&select=config:configs(id,name,config_class,type,analysis:config_analysis(id,analyzer,analysis_type,message,severity,analysis,first_observed))`,
`/analysis_by_component?component_id=eq.${id}${paginationQueryParams}&select=analysis_id,config:configs(id,name,config_class,type,analysis:config_analysis(id,analyzer,analysis_type,message,severity,analysis,first_observed))`,
{
headers: {
Prefer: "count=exact"
Expand Down
6 changes: 3 additions & 3 deletions src/components/Insights/Insights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ export default function InsightsDetails(
insights.map((item) => {
return {
...item,
sanitizedMessageHTML: sanitizeHTMLContent(item?.message),
sanitizedMessageHTML: sanitizeHTMLContent(item?.message ?? ""),
sanitizedMessageTxt: truncateText(
sanitizeHTMLContentToText(item?.message)!,
sanitizeHTMLContentToText(item?.message ?? "")!,
500
)
};
Expand Down Expand Up @@ -152,7 +152,7 @@ export default function InsightsDetails(
columns={columns}
isLoading={isLoading && !isFetching}
isFetching={isFetching}
allRows={insightsWithSanitizedMessages}
allRows={insightsWithSanitizedMessages as ConfigTypeInsights[]}
loaderView={<TextSkeletonLoader className="w-full my-2" />}
totalEntries={totalEntries}
fetchNextPage={() => {
Expand Down

0 comments on commit c556673

Please sign in to comment.