Skip to content

Commit

Permalink
need to add the lastKey logic
Browse files Browse the repository at this point in the history
  • Loading branch information
blevine-transcend committed Jan 16, 2025
1 parent dedd876 commit a4f6771
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
21 changes: 17 additions & 4 deletions src/graphql/fetchAllSiloDiscoveryRecommendations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@ import { GraphQLClient } from 'graphql-request';
import { SILO_DISCOVERY_RECOMMENDATIONS } from './gqls';
import { makeGraphQLRequest } from './makeGraphQLRequest';

export interface SiloDiscoveryRecommendation {}
export interface SiloDiscoveryRecommendation {
/** Title of silo discovery recommendation */
title: string;
/** Resource ID of silo discovery recommendation */
resourceId: string;
/** Last discovered at */
lastDiscoveredAt: string;
/** Suggested catalog */
suggestedCatalog: {
/** Title */
title: string;
};
}

const PAGE_SIZE = 20;

Expand All @@ -16,7 +28,7 @@ export async function fetchAllSiloDiscoveryRecommendations(
client: GraphQLClient,
): Promise<SiloDiscoveryRecommendation[]> {
const siloDiscoveryRecommendations: SiloDiscoveryRecommendation[] = [];
let offset = 0;
let lastKey;

// Whether to continue looping
let shouldContinue = false;
Expand All @@ -32,10 +44,11 @@ export async function fetchAllSiloDiscoveryRecommendations(
};
}>(client, SILO_DISCOVERY_RECOMMENDATIONS, {
first: PAGE_SIZE,
offset,
input: ,
filterBy:
});
siloDiscoveryRecommendations.push(...nodes);
offset += PAGE_SIZE;
lastKey = PAGE_SIZE;
shouldContinue = nodes.length === PAGE_SIZE;
} while (shouldContinue);

Expand Down
22 changes: 12 additions & 10 deletions src/graphql/gqls/siloDiscoveryRecommendation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,25 @@ export const SILO_DISCOVERY_RECOMMENDATIONS = gql`
$input: SiloDiscoveryRecommendationsInput!
$filterBy: SiloDiscoveryRecommendationFiltersInput
) {
vendors(
first: $first
offset: $offset
useMaster: false
isExportCsv: true
orderBy: [
{ field: createdAt, direction: ASC }
{ field: title, direction: ASC }
]
) {
siloDiscoveryRecommendations(first: $first, input: $input) {
nodes {
title
resourceId
lastDiscoveredAt
suggestedCatalog {
title
}
plugin {
dataSilo {
title
}
}
}
lastKey {
pluginId
resourceId
organizationId
statusLatestRunTime
}
}
}
Expand Down

0 comments on commit a4f6771

Please sign in to comment.