fix(web) fallback to search to get count (#13556)

This commit is contained in:
Jay 2025-05-30 15:17:31 -04:00 committed by GitHub
parent 4f41832ca8
commit bf174e47e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 12 additions and 4 deletions

View File

@ -78,7 +78,7 @@ export default function IngestedAssets({ id, executionResult }: Props) {
// First thing to do is to search for all assets with the id as the run id!
// Execute search
const { data, loading, error } = useGetSearchResultsForMultipleQuery({
skip: totalEntitiesIngested === null || entitiesIngestedByTypeFromReport === null,
skip: typeof totalEntitiesIngested === 'number' && !!entitiesIngestedByTypeFromReport?.length,
variables: {
input: {
query: '*',

View File

@ -91,7 +91,7 @@ describe('getEntitiesIngestedByType', () => {
};
const result = getEntitiesIngestedByType(mockExecutionRequestResult(structuredReport));
expect(result).toEqual([]);
expect(result).toBeNull();
});
test('handles aspects with non-numeric values', () => {

View File

@ -352,6 +352,10 @@ export const getEntitiesIngestedByType = (result: Partial<ExecutionRequestResult
entitiesIngestedByType[entityName] = Math.max(...(Object.values(aspects as object) as number[]));
});
if (Object.keys(entitiesIngestedByType).length === 0) {
return null;
}
return Object.entries(entitiesIngestedByType).map(([entityName, count]) => ({
count,
displayName: entityName,

View File

@ -78,7 +78,7 @@ export default function IngestedAssets({ id, executionResult }: Props) {
// First thing to do is to search for all assets with the id as the run id!
// Execute search
const { data, loading, error } = useGetSearchResultsForMultipleQuery({
skip: totalEntitiesIngested === null || entitiesIngestedByTypeFromReport === null,
skip: typeof totalEntitiesIngested === 'number' && !!entitiesIngestedByTypeFromReport?.length,
variables: {
input: {
query: '*',

View File

@ -91,7 +91,7 @@ describe('getEntitiesIngestedByType', () => {
};
const result = getEntitiesIngestedByType(mockExecutionRequestResult(structuredReport));
expect(result).toEqual([]);
expect(result).toBeNull();
});
test('handles aspects with non-numeric values', () => {

View File

@ -343,6 +343,10 @@ export const getEntitiesIngestedByType = (result: Partial<ExecutionRequestResult
entitiesIngestedByType[entityName] = Math.max(...(Object.values(aspects as object) as number[]));
});
if (Object.keys(entitiesIngestedByType).length === 0) {
return null;
}
return Object.entries(entitiesIngestedByType).map(([entityName, count]) => ({
count,
displayName: entityName,