diff --git a/src/client.ts b/src/client.ts index c7e84bdc..21f24f0d 100644 --- a/src/client.ts +++ b/src/client.ts @@ -699,6 +699,7 @@ export class APIClient { public async iterateBatchedPullRequests( repoIds: string[], + ingestStartDatetime: string, iteratee: ResourceIteratee, ): Promise { if (!this.graphQLClient) { @@ -707,6 +708,7 @@ export class APIClient { const rateLimit = await this.graphQLClient.iterateBatchedPullRequestEntities( repoIds, + ingestStartDatetime, iteratee, ); this.logger.debug( diff --git a/src/client/GraphQLClient/client.ts b/src/client/GraphQLClient/client.ts index b5d952dc..ea9f0dcc 100755 --- a/src/client/GraphQLClient/client.ts +++ b/src/client/GraphQLClient/client.ts @@ -256,6 +256,7 @@ export class GitHubGraphQLClient { public async iterateBatchedPullRequests( repoIds: string[], + ingestStartDatetime: string, iteratee: ResourceIteratee, ): Promise { const executor = createQueryExecutor(this, this.logger); @@ -264,6 +265,7 @@ export class GitHubGraphQLClient { await BatchedPullRequestsQuery.iteratePullRequests( { repoIds, + ingestStartDatetime, }, executor, iteratee, diff --git a/src/client/GraphQLClient/pullRequestQueries/BatchedPullRequestsQuery.ts b/src/client/GraphQLClient/pullRequestQueries/BatchedPullRequestsQuery.ts index acbf19ef..613a73c0 100644 --- a/src/client/GraphQLClient/pullRequestQueries/BatchedPullRequestsQuery.ts +++ b/src/client/GraphQLClient/pullRequestQueries/BatchedPullRequestsQuery.ts @@ -13,6 +13,7 @@ type QueryState = BaseQueryState; type QueryParams = { repoIds: string[]; + ingestStartDatetime: string; }; const buildQuery: BuildQuery = ( @@ -91,7 +92,15 @@ const iteratePullRequests = async ( let queryState: QueryState = {}; const executable = buildQuery(queryParams, queryState); const response = await execute(executable); - queryState = await processResponseData(response, iteratee); + const filterIteratee = async (pullRequest: PullRequestResponse) => { + if ( + new Date(pullRequest.updatedAt) >= + new Date(queryParams.ingestStartDatetime) + ) { + await iteratee(pullRequest); + } + }; + queryState = await processResponseData(response, filterIteratee); const queryCost = queryState?.rateLimit?.cost ?? 0; diff --git a/src/client/OrganizationAccountClient.ts b/src/client/OrganizationAccountClient.ts index 34c9bed2..9e87801c 100755 --- a/src/client/OrganizationAccountClient.ts +++ b/src/client/OrganizationAccountClient.ts @@ -297,13 +297,18 @@ export default class OrganizationAccountClient { async iterateBatchedPullRequestEntities( repoIds: string[], + ingestStartDatetime: string, //expect Date.toISOString format iteratee: ResourceIteratee, ): Promise { if (!this.authorizedForPullRequests) { this.logger.info('Account not authorized for ingesting pull requests.'); return { totalCost: 0 }; } - return await this.v4.iterateBatchedPullRequests(repoIds, iteratee); + return await this.v4.iterateBatchedPullRequests( + repoIds, + ingestStartDatetime, + iteratee, + ); } /** diff --git a/src/steps/pullRequests.ts b/src/steps/pullRequests.ts index 06658114..6bbbb378 100644 --- a/src/steps/pullRequests.ts +++ b/src/steps/pullRequests.ts @@ -517,7 +517,11 @@ export async function fetchPrs( totalConnectionsById: pullRequestsTotalByRepo, threshold: 25, batchCb: async (repoKeys) => { - await apiClient.iterateBatchedPullRequests(repoKeys, iteratee); + await apiClient.iterateBatchedPullRequests( + repoKeys, + ingestStartDatetime, + iteratee, + ); }, singleCb: async (repoKey) => { const repoData = repoTags.get(repoKey); diff --git a/src/steps/teams.ts b/src/steps/teams.ts index 345b1c3f..d04150ae 100644 --- a/src/steps/teams.ts +++ b/src/steps/teams.ts @@ -53,7 +53,7 @@ export async function fetchTeams({ }), ); - teamDataMap.set(teamEntity._key, { name: team.name }); + teamDataMap.set(teamEntity._key, { name: team.slug }); if (team.repositories.totalCount) { repositoriesTotalByTeam.set( teamEntity._key,