UBERF-8587: Fix github auth and delete issues (#7174)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2024-11-14 23:30:42 +07:00
committed by GitHub
parent 5ea7ff2667
commit 63294b0c66
10 changed files with 90 additions and 111 deletions
@@ -734,8 +734,8 @@ export abstract class IssueSyncManagerBase {
await this.ctx.withLog(
'create mixin issue',
{},
async () =>
await this.client.createMixin<Issue, Issue>(
() =>
this.client.createMixin<Issue, Issue>(
existing._id as Ref<GithubIssueP>,
existing._class,
existing.space,
@@ -1259,7 +1259,8 @@ export abstract class IssueSyncManagerBase {
if (!cnt) {
Analytics.handleError(err)
this.ctx.error('Error', { err })
await derivedClient.update(info, { error: errorToObj(err) })
await derivedClient.update(info, { error: errorToObj(err), needSync: githubSyncVersion })
return false
}
}
}
@@ -545,11 +545,8 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
url: issueExternal.url,
workspace: this.provider.getWorkspaceId().name
})
target.prjData = await this.ctx.withLog(
'add issue to project v2',
{},
async () =>
await this.addIssueToProject(container, okit, issueExternal, target.target.projectNodeId as string)
target.prjData = await this.ctx.withLog('add issue to project v2', {}, () =>
this.addIssueToProject(container, okit, issueExternal, target.target.projectNodeId as string)
)
if (target.prjData !== undefined) {
issueExternal.projectItems.nodes.push(target.prjData)
+18 -30
View File
@@ -129,9 +129,7 @@ export class ProjectsSyncManager implements DocSyncManager {
await this.ctx.withLog(
'Create Milestone projectV2',
{},
async () => {
await this.createMilestone(container.container, container.project, okit, milestone, info)
},
() => this.createMilestone(container.container, container.project, okit, milestone, info),
{ label: milestone.label }
)
} catch (err: any) {
@@ -148,17 +146,9 @@ export class ProjectsSyncManager implements DocSyncManager {
let { projectStructure, wasUpdates } = await this.ctx.withLog(
'update project structure',
{},
async () =>
await syncRunner.exec(
m._id,
async () =>
await this.updateFieldMappings(
container.container,
container.project,
m,
container.project.mixinClass,
okit
)
() =>
syncRunner.exec(m._id, () =>
this.updateFieldMappings(container.container, container.project, m, container.project.mixinClass, okit)
),
{ label: milestone.label }
)
@@ -168,7 +158,7 @@ export class ProjectsSyncManager implements DocSyncManager {
projectStructure = (await this.ctx.withLog(
'update project structure(sync/second step)',
{},
async () => await this.queryProjectStructure(container.container, m),
() => this.queryProjectStructure(container.container, m),
{
label: m.label
}
@@ -340,7 +330,7 @@ export class ProjectsSyncManager implements DocSyncManager {
const projectStructure = (await this.ctx.withLog(
'update project structure(handleEvent)',
{ prj: project.name },
async () => await this.queryProjectStructure(integration, project)
() => this.queryProjectStructure(integration, project)
)) as GithubProjectV2
integration.projectStructure.set(project._id, projectStructure)
@@ -423,20 +413,18 @@ export class ProjectsSyncManager implements DocSyncManager {
let { projectStructure, wasUpdates } = await this.ctx.withLog(
'update project structure',
{ prj: prj.name },
async () => await this.updateFieldMappings(integration, prj, prj, prj.mixinClass, okit)
() => this.updateFieldMappings(integration, prj, prj, prj.mixinClass, okit)
)
// Check if we have any changes in project, during our inactivity.
await this.ctx.withLog('check project v2 changes:', { prj: prj.name }, async () => {
await this.checkChanges(projectStructure, prj, prj._id, integration, derivedClient)
})
await this.ctx.withLog('check project v2 changes:', { prj: prj.name }, () =>
this.checkChanges(projectStructure, prj, prj._id, integration, derivedClient)
)
// Retrieve updated field
if (wasUpdates) {
projectStructure = (await this.ctx.withLog(
'update project structure(second pass)',
{ prj: prj.name },
async () => await this.queryProjectStructure(integration, prj)
projectStructure = (await this.ctx.withLog('update project structure(second pass)', { prj: prj.name }, () =>
this.queryProjectStructure(integration, prj)
)) as GithubProjectV2
}
@@ -459,24 +447,24 @@ export class ProjectsSyncManager implements DocSyncManager {
let { projectStructure, wasUpdates } = await this.ctx.withLog(
'update project structure',
{ prj: m.label },
async () =>
await syncRunner.exec(
() =>
syncRunner.exec(
m._id,
async () => await this.updateFieldMappings(integration, prj, m, prj.mixinClass, okit)
)
)
// Check if we have any changes in project, during our inactivity.
await this.ctx.withLog('check project v2 changes', { prj: prj.name }, async () => {
await this.checkChanges(projectStructure, m, prj._id, integration, derivedClient)
})
await this.ctx.withLog('check project v2 changes', { prj: prj.name }, () =>
this.checkChanges(projectStructure, m, prj._id, integration, derivedClient)
)
// Retrieve updated field
if (wasUpdates) {
projectStructure = (await this.ctx.withLog(
'update project structure(second pass)',
{ prj: prj.name },
async () => await this.queryProjectStructure(integration, m)
() => this.queryProjectStructure(integration, m)
)) as GithubProjectV2
}
@@ -343,12 +343,12 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
private async createSyncData (
pullRequestExternal: PullRequestExternalData,
derivedClient: TxOperations | undefined,
derivedClient: TxOperations,
repo: GithubIntegrationRepository,
account: Ref<Account>
): Promise<void> {
const lastModified = new Date(pullRequestExternal.updatedAt).getTime()
await derivedClient?.createDoc(github.class.DocSyncInfo, repo.githubProject as Ref<GithubProject>, {
await derivedClient.createDoc(github.class.DocSyncInfo, repo.githubProject as Ref<GithubProject>, {
url: pullRequestExternal.url.toLowerCase(),
needSync: '', // we need to sync to retrieve patch in background
githubNumber: pullRequestExternal.number,
@@ -426,8 +426,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
target.prjData = await this.ctx.withLog(
'add pull request to project}',
{},
async () =>
await this.addIssueToProject(container, okit, pullRequestExternal, target.target.projectNodeId as string),
() => this.addIssueToProject(container, okit, pullRequestExternal, target.target.projectNodeId as string),
{ url: pullRequestExternal.url }
)
if (target.prjData !== undefined) {
@@ -575,8 +574,8 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
await this.ctx.withLog(
'update pull request patch',
{},
async () => {
await this.handlePatch(
() =>
this.handlePatch(
info,
container,
pullRequestExternal,
@@ -587,8 +586,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
},
lastModified,
accountGH
)
},
),
{ url: pullRequestExternal.url }
)
}
@@ -606,8 +604,8 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
const update = await this.ctx.withLog(
'perform pull request diff update',
{},
async () =>
await this.handleDiffUpdate(
() =>
this.handleDiffUpdate(
target,
{ ...(existing as any), description },
info,