mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-22 20:32:24 +02:00
UBERF-9137: Fix Support for suspended installations (#7667)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -207,9 +207,9 @@ export abstract class IssueSyncManagerBase {
|
||||
})
|
||||
|
||||
if (syncData !== undefined) {
|
||||
const milestone = (
|
||||
await this.provider.liveQuery.queryFind<GithubMilestone>(github.mixin.GithubMilestone, {})
|
||||
).find((it) => it.projectNodeId === projectId)
|
||||
const milestone = await this.client.findOne<GithubMilestone>(github.mixin.GithubMilestone, {
|
||||
projectNodeId: projectId
|
||||
})
|
||||
|
||||
const target: IssueSyncTarget | undefined =
|
||||
milestone !== undefined
|
||||
@@ -264,11 +264,6 @@ export abstract class IssueSyncManagerBase {
|
||||
|
||||
let structure = integration.projectStructure.get(target.target._id)
|
||||
|
||||
const repositories = await this.provider.liveQuery.queryFind<GithubIntegrationRepository>(
|
||||
github.class.GithubIntegrationRepository,
|
||||
{}
|
||||
)
|
||||
|
||||
for (const f of target.prjData.fieldValues?.nodes ?? []) {
|
||||
if (!('id' in f)) {
|
||||
continue
|
||||
@@ -281,8 +276,13 @@ export abstract class IssueSyncManagerBase {
|
||||
needProjectRefresh = true
|
||||
}
|
||||
}
|
||||
if (needProjectRefresh) {
|
||||
const repo = repositories.find((it) => it._id === syncData.repository)
|
||||
if (needProjectRefresh && syncData.repository != null) {
|
||||
const repo = await this.provider.liveQuery.findOne<GithubIntegrationRepository>(
|
||||
github.class.GithubIntegrationRepository,
|
||||
{
|
||||
_id: syncData.repository
|
||||
}
|
||||
)
|
||||
|
||||
if (repo !== undefined) {
|
||||
await this.provider.handleEvent(github.class.GithubIntegration, integration.installationId, repo, {})
|
||||
@@ -1153,9 +1153,9 @@ export abstract class IssueSyncManagerBase {
|
||||
if (existingIssue !== undefined) {
|
||||
// Select a milestone project
|
||||
if (existingIssue.milestone != null) {
|
||||
const milestone = (
|
||||
await this.provider.liveQuery.queryFind<GithubMilestone>(github.mixin.GithubMilestone, {})
|
||||
).find((it) => it._id === existingIssue.milestone)
|
||||
const milestone = await this.provider.liveQuery.findOne<GithubMilestone>(github.mixin.GithubMilestone, {
|
||||
_id: existingIssue.milestone as Ref<GithubMilestone>
|
||||
})
|
||||
if (milestone === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -95,13 +95,15 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
|
||||
if (projectV2Event) {
|
||||
const projectV2Event = event as ProjectsV2ItemEvent
|
||||
|
||||
const githubProjects = await this.provider.liveQuery.queryFind(github.mixin.GithubProject, {})
|
||||
const githubProjects = await this.provider.liveQuery.findAll(github.mixin.GithubProject, {
|
||||
archived: false
|
||||
})
|
||||
let prj = githubProjects.find((it) => it.projectNodeId === projectV2Event.projects_v2_item.project_node_id)
|
||||
if (prj === undefined) {
|
||||
// Checking for milestones
|
||||
const m = (await this.provider.liveQuery.queryFind(github.mixin.GithubMilestone, {})).find(
|
||||
(it) => it.projectNodeId === projectV2Event.projects_v2_item.project_node_id
|
||||
)
|
||||
const m = await this.provider.liveQuery.findOne(github.mixin.GithubMilestone, {
|
||||
projectNodeId: projectV2Event.projects_v2_item.project_node_id
|
||||
})
|
||||
if (m !== undefined) {
|
||||
prj = githubProjects.find((it) => it._id === m.space)
|
||||
}
|
||||
@@ -353,13 +355,9 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
|
||||
}
|
||||
if (info.repository == null) {
|
||||
// No need to sync if component it not yet set
|
||||
const repos = (await this.provider.getProjectRepositories(container.project._id))
|
||||
.map((it) => it.name)
|
||||
.join(', ')
|
||||
this.ctx.error('Not syncing repository === null', {
|
||||
url: info.url,
|
||||
identifier: (existing as Issue).identifier,
|
||||
repos
|
||||
identifier: (existing as Issue).identifier
|
||||
})
|
||||
return { needSync: githubSyncVersion }
|
||||
}
|
||||
@@ -372,13 +370,9 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
|
||||
if (info.external === undefined && existing !== undefined) {
|
||||
const repository = await this.provider.getRepositoryById(info.repository)
|
||||
if (repository === undefined) {
|
||||
const repos = (await this.provider.getProjectRepositories(container.project._id))
|
||||
.map((it) => it.name)
|
||||
.join(', ')
|
||||
this.ctx.error('Not syncing repository === undefined', {
|
||||
url: info.url,
|
||||
identifier: (existing as Issue).identifier,
|
||||
repos
|
||||
identifier: (existing as Issue).identifier
|
||||
})
|
||||
return { needSync: githubSyncVersion }
|
||||
}
|
||||
|
||||
@@ -446,9 +446,9 @@ export class ProjectsSyncManager implements DocSyncManager {
|
||||
|
||||
if (syncConfig.SupportMilestones && integration.type === 'Organization') {
|
||||
// Check project milestones and sync their structure as well.
|
||||
const milestones = (await this.provider.liveQuery.queryFind(github.mixin.GithubMilestone, {})).filter(
|
||||
(it) => it.space === prj._id
|
||||
)
|
||||
const milestones = await this.provider.liveQuery.findAll(github.mixin.GithubMilestone, {
|
||||
space: prj._id
|
||||
})
|
||||
for (const m of milestones) {
|
||||
if (this.provider.isClosing()) {
|
||||
break
|
||||
|
||||
@@ -100,13 +100,15 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
|
||||
if (projectV2Event) {
|
||||
const projectV2Event = _event as ProjectsV2ItemEvent
|
||||
|
||||
const githubProjects = await this.provider.liveQuery.queryFind(github.mixin.GithubProject, {})
|
||||
const githubProjects = await this.provider.liveQuery.findAll(github.mixin.GithubProject, {
|
||||
archived: false
|
||||
})
|
||||
let prj = githubProjects.find((it) => it.projectNodeId === projectV2Event.projects_v2_item.project_node_id)
|
||||
if (prj === undefined) {
|
||||
// Checking for milestones
|
||||
const m = (await this.provider.liveQuery.queryFind(github.mixin.GithubMilestone, {})).find(
|
||||
(it) => it.projectNodeId === projectV2Event.projects_v2_item.project_node_id
|
||||
)
|
||||
const m = await this.provider.liveQuery.findOne(github.mixin.GithubMilestone, {
|
||||
projectNodeId: projectV2Event.projects_v2_item.project_node_id
|
||||
})
|
||||
if (m !== undefined) {
|
||||
prj = githubProjects.find((it) => it._id === m.space)
|
||||
}
|
||||
|
||||
@@ -48,9 +48,9 @@ export class RepositorySyncMapper implements DocSyncManager {
|
||||
if (repositories !== undefined) {
|
||||
// We have a list of repositories, so we could create them if they are missing.
|
||||
// Need to find all repositories, not only active, so passed repositories are not work.
|
||||
const allRepositories = (
|
||||
await this.provider.liveQuery.queryFind(github.class.GithubIntegrationRepository, {})
|
||||
).filter((it) => it.attachedTo === integration.integration._id)
|
||||
const allRepositories = await this.provider.liveQuery.findAll(github.class.GithubIntegrationRepository, {
|
||||
attachedTo: integration.integration._id
|
||||
})
|
||||
|
||||
const allRepos: GithubIntegrationRepository[] = [...allRepositories]
|
||||
for (const repository of repositories) {
|
||||
@@ -259,9 +259,9 @@ export class RepositorySyncMapper implements DocSyncManager {
|
||||
const iterable = this.app.eachRepository.iterator({ installationId: integration.installationId })
|
||||
|
||||
// Need to find all repositories, not only active, so passed repositories are not work.
|
||||
const allRepositories = (
|
||||
await this.provider.liveQuery.queryFind(github.class.GithubIntegrationRepository, {})
|
||||
).filter((it) => it.attachedTo === integration.integration._id)
|
||||
const allRepositories = await this.provider.liveQuery.findAll(github.class.GithubIntegrationRepository, {
|
||||
attachedTo: integration.integration._id
|
||||
})
|
||||
|
||||
let allRepos: GithubIntegrationRepository[] = [...allRepositories]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user