mirror of
https://github.com/hexastack/hexabot
synced 2025-05-05 21:34:41 +00:00
fix: update nlpEntity model injection
This commit is contained in:
parent
f18c061888
commit
a729fe2f15
@ -9,13 +9,7 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { InjectModel } from '@nestjs/mongoose';
|
import { InjectModel } from '@nestjs/mongoose';
|
||||||
import { plainToClass } from 'class-transformer';
|
import { plainToClass } from 'class-transformer';
|
||||||
import mongoose, {
|
import { Document, Model, PipelineStage, Query, Types } from 'mongoose';
|
||||||
Document,
|
|
||||||
Model,
|
|
||||||
PipelineStage,
|
|
||||||
Query,
|
|
||||||
Types,
|
|
||||||
} from 'mongoose';
|
|
||||||
|
|
||||||
import { BaseRepository, DeleteResult } from '@/utils/generics/base-repository';
|
import { BaseRepository, DeleteResult } from '@/utils/generics/base-repository';
|
||||||
import { PageQueryDto } from '@/utils/pagination/pagination-query.dto';
|
import { PageQueryDto } from '@/utils/pagination/pagination-query.dto';
|
||||||
@ -23,7 +17,7 @@ import { TFilterQuery } from '@/utils/types/filter.types';
|
|||||||
import { Format } from '@/utils/types/format.types';
|
import { Format } from '@/utils/types/format.types';
|
||||||
|
|
||||||
import { NlpValueDto } from '../dto/nlp-value.dto';
|
import { NlpValueDto } from '../dto/nlp-value.dto';
|
||||||
import { NlpEntity, NlpEntityModel } from '../schemas/nlp-entity.schema';
|
import { NlpEntity } from '../schemas/nlp-entity.schema';
|
||||||
import {
|
import {
|
||||||
NLP_VALUE_POPULATE,
|
NLP_VALUE_POPULATE,
|
||||||
NlpValue,
|
NlpValue,
|
||||||
@ -47,6 +41,8 @@ export class NlpValueRepository extends BaseRepository<
|
|||||||
constructor(
|
constructor(
|
||||||
@InjectModel(NlpValue.name) readonly model: Model<NlpValue>,
|
@InjectModel(NlpValue.name) readonly model: Model<NlpValue>,
|
||||||
private readonly nlpSampleEntityRepository: NlpSampleEntityRepository,
|
private readonly nlpSampleEntityRepository: NlpSampleEntityRepository,
|
||||||
|
@InjectModel(NlpEntity.name)
|
||||||
|
private readonly nlpEntityModel: Model<NlpEntity>,
|
||||||
) {
|
) {
|
||||||
super(model, NlpValue, NLP_VALUE_POPULATE, NlpValueFull);
|
super(model, NlpValue, NLP_VALUE_POPULATE, NlpValueFull);
|
||||||
}
|
}
|
||||||
@ -249,14 +245,11 @@ export class NlpValueRepository extends BaseRepository<
|
|||||||
for (const item of aggregatedResults as TNlpValueCount<F>[]) {
|
for (const item of aggregatedResults as TNlpValueCount<F>[]) {
|
||||||
if (format === Format.FULL) {
|
if (format === Format.FULL) {
|
||||||
const { entity, ...rest } = item;
|
const { entity, ...rest } = item;
|
||||||
const entityData = await mongoose
|
const nlpEntityData = await this.nlpEntityModel.findById(entity).lean();
|
||||||
.model(NlpEntityModel.name, NlpEntityModel.schema)
|
|
||||||
.findById(entity)
|
|
||||||
.lean();
|
|
||||||
|
|
||||||
const plainNlpValue: NlpValueFull = {
|
const plainNlpValue: NlpValueFull = {
|
||||||
...rest,
|
...rest,
|
||||||
entity: plainToClass(NlpEntity, entityData, {
|
entity: plainToClass(NlpEntity, nlpEntityData, {
|
||||||
excludePrefixes: ['_'],
|
excludePrefixes: ['_'],
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user