diff --git a/modules/authorization/src/admin/index.ts b/modules/authorization/src/admin/index.ts index 3d41ed1b6..a0c239d0a 100644 --- a/modules/authorization/src/admin/index.ts +++ b/modules/authorization/src/admin/index.ts @@ -5,7 +5,11 @@ import { ParsedRouterRequest, UnparsedRouterResponse, } from '@conduitplatform/grpc-sdk'; -import { GrpcServer, RoutingManager } from '@conduitplatform/module-tools'; +import { + ConduitBoolean, + GrpcServer, + RoutingManager, +} from '@conduitplatform/module-tools'; import { ResourceHandler } from './resources.js'; import { RelationHandler } from './relations.js'; import { @@ -15,6 +19,7 @@ import { ResourceDefinition, } from '../models/index.js'; import { QueueController } from '../controllers/index.js'; +import { isNil } from 'lodash-es'; export class AdminHandlers { private readonly resourceHandler: ResourceHandler; @@ -37,11 +42,14 @@ export class AdminHandlers { ) { // used to trigger an index re-construction ConduitGrpcSdk.Logger.warn('Reconstructing indices...'); - ConduitGrpcSdk.Logger.warn('Wiping index data...'); - await Promise.all([ - ActorIndex.getInstance().deleteMany({}), - ObjectIndex.getInstance().deleteMany({}), - ]); + if (isNil(call.request.bodyParams.soft) || call.request.bodyParams.soft === false) { + ConduitGrpcSdk.Logger.warn('Wiping index data...'); + await Promise.all([ + ActorIndex.getInstance().deleteMany({}), + ObjectIndex.getInstance().deleteMany({}), + ]); + } + callback('ok'); ConduitGrpcSdk.Logger.warn('Beginning index reconstruction...'); const resources = await ResourceDefinition.getInstance().findMany({}); @@ -88,6 +96,9 @@ export class AdminHandlers { { path: '/indexer/reconstruct', action: ConduitRouteActions.POST, + bodyParams: { + soft: ConduitBoolean.Optional, + }, description: `Wipes and re-constructs the relation indexes.`, }, new ConduitRouteReturnDefinition('IndexReconstruct', 'String'), diff --git a/modules/authorization/src/controllers/queue.controller.ts b/modules/authorization/src/controllers/queue.controller.ts index 32ab0c6b4..098b34c08 100644 --- a/modules/authorization/src/controllers/queue.controller.ts +++ b/modules/authorization/src/controllers/queue.controller.ts @@ -51,10 +51,10 @@ export class QueueController { // autorun: true, }); worker.on('active', job => { - ConduitGrpcSdk.Logger.info(`Job ${job.id} started`); + ConduitGrpcSdk.Logger.info(`Index ${job.id} started`); }); worker.on('completed', job => { - ConduitGrpcSdk.Logger.info(`Job ${job.id} completed`); + ConduitGrpcSdk.Logger.info(`Index ${job.id} completed`); }); worker.on('error', (error: Error) => { ConduitGrpcSdk.Logger.error(`Job error:`); @@ -84,10 +84,10 @@ export class QueueController { // autorun: true, }); worker.on('active', job => { - ConduitGrpcSdk.Logger.info(`Job ${job.id} started`); + ConduitGrpcSdk.Logger.info(`Connection ${job.id} started`); }); worker.on('completed', job => { - ConduitGrpcSdk.Logger.info(`Job ${job.id} completed`); + ConduitGrpcSdk.Logger.info(`Connection ${job.id} completed`); }); worker.on('error', error => { ConduitGrpcSdk.Logger.error(`Job error:`);