mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-13 02:41:11 +00:00
Allow to reindex region (#8610)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
2326643ccc
commit
10c30e6cc0
@ -229,7 +229,7 @@ export function devTool (
|
|||||||
const uri = dbOverride ?? getAccountDBUrl()
|
const uri = dbOverride ?? getAccountDBUrl()
|
||||||
console.log(`connecting to database '${uri}'...`)
|
console.log(`connecting to database '${uri}'...`)
|
||||||
|
|
||||||
const [accountDb, closeAccountsDb] = await getAccountDB(uri)
|
const [accountDb, closeAccountsDb] = await getAccountDB(uri, process.env.DB_NS)
|
||||||
try {
|
try {
|
||||||
await f(accountDb)
|
await f(accountDb)
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
@ -2104,7 +2104,8 @@ export function devTool (
|
|||||||
program
|
program
|
||||||
.command('fulltext-reindex-all')
|
.command('fulltext-reindex-all')
|
||||||
.description('reindex workspaces')
|
.description('reindex workspaces')
|
||||||
.action(async () => {
|
.option('--region <region>', 'region to reindex')
|
||||||
|
.action(async (cmd: { region?: string }) => {
|
||||||
const fulltextUrl = process.env.FULLTEXT_URL
|
const fulltextUrl = process.env.FULLTEXT_URL
|
||||||
if (fulltextUrl === undefined) {
|
if (fulltextUrl === undefined) {
|
||||||
console.error('please provide FULLTEXT_URL')
|
console.error('please provide FULLTEXT_URL')
|
||||||
@ -2112,16 +2113,19 @@ export function devTool (
|
|||||||
}
|
}
|
||||||
|
|
||||||
await withAccountDatabase(async (db) => {
|
await withAccountDatabase(async (db) => {
|
||||||
const workspaces = await listWorkspacesRaw(db)
|
const workspaces = (await listWorkspacesRaw(db, cmd.region)).filter(
|
||||||
|
(it) => isActiveMode(it.mode) && it.version?.patch === getModelVersion().patch
|
||||||
|
)
|
||||||
workspaces.sort((a, b) => b.lastVisit - a.lastVisit)
|
workspaces.sort((a, b) => b.lastVisit - a.lastVisit)
|
||||||
|
console.log('workspacess to process', workspaces.length)
|
||||||
for (const workspace of workspaces) {
|
for (const workspace of workspaces) {
|
||||||
const wsid = getWorkspaceId(workspace.workspace)
|
const wsid = getWorkspaceId(workspace.workspace)
|
||||||
const token = generateToken(systemAccountEmail, wsid)
|
const token = generateToken(systemAccountEmail, wsid)
|
||||||
|
|
||||||
console.log('reindex workspace', workspace)
|
console.log('reindex workspace', workspace.workspaceUrl)
|
||||||
await reindexWorkspace(toolCtx, fulltextUrl, token)
|
await reindexWorkspace(toolCtx, fulltextUrl, token)
|
||||||
console.log('done', workspace)
|
|
||||||
}
|
}
|
||||||
|
console.log('end-reindex')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user