Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
garrrikkotua committed Aug 1, 2024
1 parent 14bf889 commit 6331cb1
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions backend/src/database/repositories/segmentRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,25 +725,29 @@ class SegmentRepository extends RepositoryBase<
const rows = projects.map((i) => removeFieldsFromObject(i, 'totalCount'))

// assign integrations to subprojects
await Promise.all(rows.map(async (row) => {
await Promise.all(row.subprojects.map(async (subproject) => {
const integrations = integrationsBySegments[subproject.id] || []
const githubIntegration = integrations.find(i => i.platform === 'github')

if (githubIntegration) {
githubIntegration.type = 'primary'
} else if (mappedGithubReposBySegments[subproject.id]) {
integrations.push({
platform: 'github',
segmentId: subproject.id,
type: 'mapped',
mappedWith: await this.mappedWith(subproject.id),
})
}

subproject.integrations = integrations
}))
}))
await Promise.all(
rows.map(async (row) => {
await Promise.all(
row.subprojects.map(async (subproject) => {
const integrations = integrationsBySegments[subproject.id] || []
const githubIntegration = integrations.find((i) => i.platform === 'github')

if (githubIntegration) {
githubIntegration.type = 'primary'
} else if (mappedGithubReposBySegments[subproject.id]) {
integrations.push({
platform: 'github',
segmentId: subproject.id,
type: 'mapped',
mappedWith: await this.mappedWith(subproject.id),
})
}

subproject.integrations = integrations
}),
)
}),
)

return { count, rows, limit: criteria.limit, offset: criteria.offset }
}
Expand Down

0 comments on commit 6331cb1

Please sign in to comment.