diff --git a/dev/tool/package.json b/dev/tool/package.json index 8b7e46df07..0534763986 100644 --- a/dev/tool/package.json +++ b/dev/tool/package.json @@ -14,6 +14,7 @@ "docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/tool staging", "docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/tool", "run-local": "cross-env SERVER_SECRET=secret MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost MONGO_URL=mongodb://localhost:27017 TRANSACTOR_URL=ws:/localhost:3333 TELEGRAM_DATABASE=telegram-service ELASTIC_URL=http://localhost:9200 REKONI_URL=http://localhost:4004 ts-node ./src/index.ts", + "run": "cross-env ts-node ./src/index.ts", "upgrade": "rushx run-local upgrade", "lint": "eslint src", "format": "prettier --write src && eslint --fix src" diff --git a/dev/tool/src/index.ts b/dev/tool/src/index.ts index 25e6f10b96..a708fd48af 100644 --- a/dev/tool/src/index.ts +++ b/dev/tool/src/index.ts @@ -44,8 +44,6 @@ import { updateCandidates } from './recruit' import { clearTelegramHistory } from './telegram' import { diffWorkspace, dumpWorkspace, restoreWorkspace } from './workspace' -const { mongodbUri, minio } = prepareTools() - const serverSecret = process.env.SERVER_SECRET if (serverSecret === undefined) { console.error('please provide server secret') @@ -58,10 +56,13 @@ if (transactorUrl === undefined) { process.exit(1) } -const elasticUrl = process.env.ELASTIC_URL -if (elasticUrl === undefined) { - console.error('please provide elastic url') - process.exit(1) +function getElasticUrl (): string { + const elasticUrl = process.env.ELASTIC_URL + if (elasticUrl === undefined) { + console.error('please provide elastic url') + process.exit(1) + } + return elasticUrl } setMetadata(toolPlugin.metadata.Endpoint, transactorUrl) @@ -86,6 +87,7 @@ program .requiredOption('-f, --first ', 'first name') .requiredOption('-l, --last ', 'last name') .action(async (email: string, cmd) => { + const { mongodbUri } = prepareTools() return await withDatabase(mongodbUri, async (db) => { console.log(`creating account ${cmd.first as string} ${cmd.last as string} (${email})...`) await createAccount(db, email, cmd.password, cmd.first, cmd.last) @@ -96,6 +98,7 @@ program .command('assign-workspace ') .description('assign workspace') .action(async (email: string, workspace: string, cmd) => { + const { mongodbUri } = prepareTools() return await withDatabase(mongodbUri, async (db, client) => { console.log(`assigning user ${email} to ${workspace}...`) await assignWorkspace(db, email, workspace) @@ -106,6 +109,7 @@ program .command('show-user ') .description('show user') .action(async (email) => { + const { mongodbUri } = prepareTools() return await withDatabase(mongodbUri, async (db) => { const info = await getAccount(db, email) console.log(info) @@ -117,6 +121,7 @@ program .description('create workspace') .requiredOption('-o, --organization ', 'organization name') .action(async (workspace, cmd) => { + const { mongodbUri } = prepareTools() return await withDatabase(mongodbUri, async (db) => { await createWorkspace(db, workspace, cmd.organization) }) @@ -134,6 +139,7 @@ program .command('upgrade-workspace ') .description('upgrade workspace') .action(async (workspace, cmd) => { + const { mongodbUri } = prepareTools() return await withDatabase(mongodbUri, async (db) => { await upgradeWorkspace(db, workspace) }) @@ -143,6 +149,7 @@ program .command('upgrade') .description('upgrade') .action(async (cmd) => { + const { mongodbUri } = prepareTools() return await withDatabase(mongodbUri, async (db) => { const workspaces = await listWorkspaces(db) for (const ws of workspaces) { @@ -156,6 +163,7 @@ program .command('drop-workspace ') .description('drop workspace') .action(async (workspace, cmd) => { + const { mongodbUri } = prepareTools() return await withDatabase(mongodbUri, async (db) => { const ws = await getWorkspace(db, workspace) if (ws === null) { @@ -170,6 +178,7 @@ program .command('list-workspaces') .description('List workspaces') .action(async () => { + const { mongodbUri } = prepareTools() return await withDatabase(mongodbUri, async (db) => { const workspacesJSON = JSON.stringify(await listWorkspaces(db), null, 2) console.info(workspacesJSON) @@ -182,6 +191,7 @@ program .command('show-accounts') .description('Show accounts') .action(async () => { + const { mongodbUri } = prepareTools() return await withDatabase(mongodbUri, async (db) => { const accountsJSON = JSON.stringify(await listAccounts(db), null, 2) console.info(accountsJSON) @@ -192,6 +202,7 @@ program .command('drop-account ') .description('drop account') .action(async (email, cmd) => { + const { mongodbUri } = prepareTools() return await withDatabase(mongodbUri, async (db) => { await dropAccount(db, email) }) @@ -201,6 +212,7 @@ program .command('dump-workspace ') .description('dump workspace transactions and minio resources') .action(async (workspace, dirName, cmd) => { + const { mongodbUri, minio } = prepareTools() return await dumpWorkspace(mongodbUri, workspace, dirName, minio) }) @@ -232,6 +244,7 @@ program .command('backup-s3 ') .description('dump workspace transactions and minio resources') .action(async (bucketName, dirName, workspace, cmd) => { + const { minio } = prepareTools() const storage = await createMinioBackupStorage(minio, bucketName, dirName) return await backup(transactorUrl, workspace, storage) }) @@ -239,6 +252,7 @@ program .command('backup-s3-restore , [date]') .description('dump workspace transactions and minio resources') .action(async (bucketName, dirName, workspace, date, cmd) => { + const { minio } = prepareTools() const storage = await createMinioBackupStorage(minio, bucketName, dirName) return await restore(transactorUrl, workspace, storage, parseInt(date ?? '-1')) }) @@ -246,6 +260,7 @@ program .command('backup-s3-list ') .description('list snaphost ids for backup') .action(async (bucketName, dirName, cmd) => { + const { minio } = prepareTools() const storage = await createMinioBackupStorage(minio, bucketName, dirName) return await backupList(storage) }) @@ -254,13 +269,15 @@ program .command('restore-workspace ') .description('restore workspace transactions and minio resources from previous dump.') .action(async (workspace, dirName, cmd) => { - return await restoreWorkspace(mongodbUri, workspace, dirName, minio, elasticUrl, transactorUrl) + const { mongodbUri, minio } = prepareTools() + return await restoreWorkspace(mongodbUri, workspace, dirName, minio, getElasticUrl(), transactorUrl) }) program .command('diff-workspace ') .description('restore workspace transactions and minio resources from previous dump.') .action(async (workspace, cmd) => { + const { mongodbUri } = prepareTools() return await diffWorkspace(mongodbUri, workspace) }) @@ -269,6 +286,7 @@ program .description('clear telegram history') .option('-w, --workspace ', 'target workspace') .action(async (workspace: string, cmd) => { + const { mongodbUri, minio } = prepareTools() return await withDatabase(mongodbUri, async (db) => { const telegramDB = process.env.TELEGRAM_DATABASE if (telegramDB === undefined) { @@ -285,6 +303,7 @@ program .command('clear-telegram-all-history') .description('clear telegram history') .action(async (cmd) => { + const { mongodbUri, minio } = prepareTools() return await withDatabase(mongodbUri, async (db) => { const telegramDB = process.env.TELEGRAM_DATABASE if (telegramDB === undefined) { @@ -305,15 +324,16 @@ program .command('rebuild-elastic [workspace]') .description('rebuild elastic index') .action(async (workspace, cmd) => { + const { mongodbUri, minio } = prepareTools() return await withDatabase(mongodbUri, async (db) => { if (workspace === undefined) { const workspaces = await listWorkspaces(db) for (const w of workspaces) { - await rebuildElastic(mongodbUri, w.workspace, minio, elasticUrl) + await rebuildElastic(mongodbUri, w.workspace, minio, getElasticUrl()) } } else { - await rebuildElastic(mongodbUri, workspace, minio, elasticUrl) + await rebuildElastic(mongodbUri, workspace, minio, getElasticUrl()) console.log('rebuild end') } }) @@ -323,7 +343,8 @@ program .command('import-xml ') .description('Import Talants.') .action(async (workspace, fileName, cmd) => { - return await importXml(transactorUrl, workspace, minio, fileName, mongodbUri, elasticUrl) + const { mongodbUri, minio } = prepareTools() + return await importXml(transactorUrl, workspace, minio, fileName, mongodbUri, getElasticUrl()) }) program @@ -368,7 +389,8 @@ program console.log('Please provide REKONI_URL environment variable') exit(1) } - return await updateCandidates(transactorUrl, workspace, minio, mongodbUri, elasticUrl, rekoniUrl) + const { mongodbUri, minio } = prepareTools() + return await updateCandidates(transactorUrl, workspace, minio, mongodbUri, getElasticUrl(), rekoniUrl) }) program.parse(process.argv) diff --git a/plugins/tracker-resources/src/components/issues/IssueStatusIcon.svelte b/plugins/tracker-resources/src/components/issues/IssueStatusIcon.svelte index fd981ee223..25c0e2760b 100644 --- a/plugins/tracker-resources/src/components/issues/IssueStatusIcon.svelte +++ b/plugins/tracker-resources/src/components/issues/IssueStatusIcon.svelte @@ -31,8 +31,9 @@ if (status.$lookup?.category) { category = status.$lookup.category } - - category = await client.findOne(tracker.class.IssueStatusCategory, { _id: value.category }) + if (category === undefined) { + category = await client.findOne(tracker.class.IssueStatusCategory, { _id: value.category }) + } } $: updateCategory(value)