mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-28 10:49:45 +02:00
QFIX: Github migration + few checks (#9244)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -96,7 +96,7 @@ const config: Config = (() => {
|
||||
|
||||
SentryDSN: process.env[envMap.SentryDSN],
|
||||
BrandingPath: process.env[envMap.BrandingPath] ?? '',
|
||||
WorkspaceInactivityInterval: parseInt(process.env[envMap.WorkspaceInactivityInterval] ?? '5'), // In days
|
||||
WorkspaceInactivityInterval: parseInt(process.env[envMap.WorkspaceInactivityInterval] ?? '3'), // In days
|
||||
RateLimit: parseInt(process.env[envMap.RateLimit] ?? '25')
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import core, {
|
||||
systemAccountUuid,
|
||||
TimeRateLimiter,
|
||||
TxOperations,
|
||||
versionToString,
|
||||
WorkspaceInfoWithStatus,
|
||||
WorkspaceUuid,
|
||||
type PersonUuid,
|
||||
@@ -866,17 +867,24 @@ export class PlatformWorker {
|
||||
const rateLimiter = new RateLimiter(5)
|
||||
const rechecks: string[] = []
|
||||
let idx = 0
|
||||
const connecting = new Map<string, number>()
|
||||
const connecting = new Map<
|
||||
string,
|
||||
{
|
||||
time: number
|
||||
version: string
|
||||
}
|
||||
>()
|
||||
const st = Date.now()
|
||||
const connectingInfo = setInterval(() => {
|
||||
this.ctx.info('****** connecting to workspaces ******', {
|
||||
connecting: connecting.size,
|
||||
time: Date.now() - st,
|
||||
workspaces: workspaces.length,
|
||||
connected: this.clients.size,
|
||||
queue: rateLimiter.processingQueue.size
|
||||
})
|
||||
for (const [c, d] of connecting.entries()) {
|
||||
this.ctx.info('connecting to workspace', { workspace: c, time: Date.now() - d })
|
||||
this.ctx.info('connecting to workspace', { workspace: c, time: Date.now() - d.time, version: d.version })
|
||||
}
|
||||
}, 5000)
|
||||
for (const workspace of workspaces) {
|
||||
@@ -898,10 +906,21 @@ export class PlatformWorker {
|
||||
const branding = Object.values(this.brandingMap).find((b) => b.key === workspaceInfo?.branding) ?? null
|
||||
const workerCtx = this.ctx.newChild('worker', { workspace: workspaceInfo.uuid }, {})
|
||||
|
||||
connecting.set(workspaceInfo.uuid, Date.now())
|
||||
connecting.set(workspaceInfo.uuid, {
|
||||
time: Date.now(),
|
||||
version: versionToString({
|
||||
major: workspaceInfo.versionMajor,
|
||||
minor: workspaceInfo.versionMinor,
|
||||
patch: workspaceInfo.versionPatch
|
||||
})
|
||||
})
|
||||
workerCtx.info('************************* Register worker ************************* ', {
|
||||
workspaceId: workspaceInfo.uuid,
|
||||
workspaceUrl: workspaceInfo.url,
|
||||
versionMajor: workspaceInfo.versionMajor,
|
||||
versionMinor: workspaceInfo.versionMinor,
|
||||
versionPatch: workspaceInfo.versionPatch,
|
||||
mode: workspaceInfo.mode,
|
||||
index: widx,
|
||||
total: workspaces.length
|
||||
})
|
||||
@@ -962,6 +981,10 @@ export class PlatformWorker {
|
||||
{
|
||||
workspaceId: workspaceInfo.uuid,
|
||||
workspaceUrl: workspaceInfo.url,
|
||||
versionMajor: workspaceInfo.versionMajor,
|
||||
versionMinor: workspaceInfo.versionMinor,
|
||||
versionPatch: workspaceInfo.versionPatch,
|
||||
lastVisit: (Date.now() - (workspaceInfo.lastVisit ?? 0)) / (24 * 60 * 60 * 1000),
|
||||
index: widx,
|
||||
total: workspaces.length
|
||||
}
|
||||
|
||||
@@ -328,16 +328,19 @@ export class CommentSyncManager implements DocSyncManager {
|
||||
if (Object.keys(platformUpdate).length > 0) {
|
||||
// Check and update body with external
|
||||
const okit = (await this.provider.getOctokit(existing.modifiedBy)) ?? container.container.octokit
|
||||
await okit?.rest.issues.updateComment({
|
||||
owner: repository.owner?.login as string,
|
||||
repo: repository.name,
|
||||
issue_number: parent.githubNumber,
|
||||
comment_id: comment.id,
|
||||
body: await this.provider.getMarkdown(existingComment.message),
|
||||
headers: {
|
||||
'X-GitHub-Api-Version': '2022-11-28'
|
||||
}
|
||||
})
|
||||
const mdown = await this.provider.getMarkdown(existingComment.message)
|
||||
if (mdown.trim().length > 0) {
|
||||
await okit?.rest.issues.updateComment({
|
||||
owner: repository.owner?.login as string,
|
||||
repo: repository.name,
|
||||
issue_number: parent.githubNumber,
|
||||
comment_id: comment.id,
|
||||
body: mdown,
|
||||
headers: {
|
||||
'X-GitHub-Api-Version': '2022-11-28'
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
if (Object.keys(update).length > 0) {
|
||||
await this.client.update(existing, update, false, new Date(comment.updated_at).getTime(), account)
|
||||
@@ -400,24 +403,29 @@ export class CommentSyncManager implements DocSyncManager {
|
||||
|
||||
// No external version yet, create it.
|
||||
try {
|
||||
const result = await okit?.rest.issues.createComment({
|
||||
owner: repo.owner?.login as string,
|
||||
repo: repo.name,
|
||||
issue_number: parent.githubNumber,
|
||||
body: await this.provider.getMarkdown(chatMessage.message),
|
||||
headers: {
|
||||
'X-GitHub-Api-Version': '2022-11-28'
|
||||
const mdown = await this.provider.getMarkdown(chatMessage.message)
|
||||
if (mdown.trim().length > 0) {
|
||||
const result = await okit?.rest.issues.createComment({
|
||||
owner: repo.owner?.login as string,
|
||||
repo: repo.name,
|
||||
issue_number: parent.githubNumber,
|
||||
body: mdown,
|
||||
headers: {
|
||||
'X-GitHub-Api-Version': '2022-11-28'
|
||||
}
|
||||
})
|
||||
|
||||
const upd: DocumentUpdate<DocSyncInfo> = {
|
||||
parent: (result?.data.html_url?.split('#')?.[0] ?? '').toLowerCase(),
|
||||
url: (result?.data.url ?? '').toLowerCase(),
|
||||
external: result?.data as CommentExternalData,
|
||||
current: result?.data,
|
||||
repository: repo._id
|
||||
}
|
||||
})
|
||||
const upd: DocumentUpdate<DocSyncInfo> = {
|
||||
parent: (result?.data.html_url?.split('#')?.[0] ?? '').toLowerCase(),
|
||||
url: (result?.data.url ?? '').toLowerCase(),
|
||||
external: result?.data as CommentExternalData,
|
||||
current: result?.data,
|
||||
repository: repo._id
|
||||
|
||||
// We need to update in current promise, to prevent event changes.
|
||||
await derivedClient.update(info, upd)
|
||||
}
|
||||
// We need to update in current promise, to prevent event changes.
|
||||
await derivedClient.update(info, upd)
|
||||
return {}
|
||||
} catch (err: any) {
|
||||
Analytics.handleError(err)
|
||||
|
||||
@@ -99,7 +99,7 @@ export abstract class IssueSyncManagerBase {
|
||||
// Find Assignees and reviewers
|
||||
const assignees: PersonId[] = []
|
||||
|
||||
for (const o of issue.assignees.nodes ?? []) {
|
||||
for (const o of issue.assignees?.nodes ?? []) {
|
||||
const acc = await this.provider.getAccount(o)
|
||||
if (acc !== undefined) {
|
||||
assignees.push(acc)
|
||||
|
||||
@@ -1717,6 +1717,7 @@ export class GithubWorker implements IntegrationManager {
|
||||
;({ client, endpoint } = await createPlatformClient(workspace.uuid, 30000, async (event: ClientConnectEvent) => {
|
||||
reconnect(workspace.uuid, event)
|
||||
}))
|
||||
ctx.info('connected to github', { workspace: workspace.uuid, endpoint })
|
||||
|
||||
const githubEnabled = (await client.findOne(core.class.PluginConfiguration, { pluginId: githubId }))?.enabled
|
||||
if (githubEnabled === false) {
|
||||
|
||||
Reference in New Issue
Block a user