Skip to content

Commit cbab62f

Browse files
committed
fix: projects metadata on github nango
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
1 parent 94324f2 commit cbab62f

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

backend/src/services/integrationService.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,17 @@ export default class IntegrationService {
195195
const { segmentId, id: insightsProjectId } = insightsProject
196196
const { platform } = data
197197

198-
await this.updateInsightsProject({
199-
insightsProjectId,
200-
isFirstUpdate: true,
201-
platform,
202-
segmentId,
203-
transaction,
204-
})
198+
// Skip for GITHUB_NANGO: repos aren't available at create time.
199+
// - GITHUB_NANGO: repos stripped from settings; githubNangoConnect calls updateInsightsProject after mapGithubRepos populates public.repositories.
200+
if (platform !== PlatformType.GITHUB_NANGO) {
201+
await this.updateInsightsProject({
202+
insightsProjectId,
203+
isFirstUpdate: true,
204+
platform,
205+
segmentId,
206+
transaction,
207+
})
208+
}
205209

206210
return integration
207211
} catch (error) {
@@ -836,6 +840,21 @@ export default class IntegrationService {
836840

837841
// create github mapping - this also creates git integration
838842
await txService.mapGithubRepos(integration.id, mapping, false, forkedFromMap)
843+
844+
// Re-run updateInsightsProject now that repos are mapped, so metadata can be fetched
845+
const collectionService = new CollectionService(txOptions)
846+
const [insightsProject] = await collectionService.findInsightsProjectsBySegmentId(
847+
integration.segmentId,
848+
)
849+
if (insightsProject) {
850+
await txService.updateInsightsProject({
851+
insightsProjectId: insightsProject.id,
852+
isFirstUpdate: true,
853+
platform: PlatformType.GITHUB_NANGO,
854+
segmentId: insightsProject.segmentId,
855+
transaction,
856+
})
857+
}
839858
} else {
840859
// update existing integration
841860
integration = await txService.findById(integrationId)

0 commit comments

Comments
 (0)