Skip to content

Commit

Permalink
fix: delete duplicate field search field
Browse files Browse the repository at this point in the history
  • Loading branch information
caoxing9 committed Jan 20, 2025
1 parent d13cc18 commit e665a02
Showing 1 changed file with 45 additions and 47 deletions.
92 changes: 45 additions & 47 deletions apps/nestjs-backend/src/features/record/record.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import type {
} from '@teable/openapi';
import { GroupPointType, UploadType } from '@teable/openapi';
import { Knex } from 'knex';
import { get, difference, keyBy, orderBy } from 'lodash';
import { get, difference, keyBy, orderBy, uniqBy } from 'lodash';
import { InjectModel } from 'nest-knexjs';
import { ClsService } from 'nestjs-cls';
import { CacheService } from '../../cache/cache.service';
Expand Down Expand Up @@ -413,15 +413,10 @@ export class RecordService {
}

if (!fieldIdOrName) {
return [
searchValue,
Object.values(fieldMap)
.map((f) => f.id)
.join(','),
hideNotMatchRow,
];
return [searchValue, fieldIdOrName, hideNotMatchRow];
}
const fieldIds = fieldIdOrName.split(',');

const fieldIds = fieldIdOrName?.split(',');

fieldIds.forEach((id) => {
const field = fieldMap[id];
Expand Down Expand Up @@ -1381,45 +1376,48 @@ export class RecordService {
});
}

return orderBy(
Object.values(fieldInstanceMap)
.map((field) => ({
...field,
isStructuredCellValue: field.isStructuredCellValue,
}))
.filter((field) => {
if (!viewColumnMeta) {
return true;
}
return !viewColumnMeta?.[field.id]?.hidden;
})
.filter((field) => {
if (!projection) {
return true;
}
return projection.includes(field.id);
})
.filter((field) => {
if (!search?.[1]) {
return true;
}

const searchArr = search[1].split(',');
return searchArr.includes(field.id);
})
.filter((field) => {
if (field.dbFieldType === DbFieldType.Boolean) {
return false;
}
return true;
})
.map((field) => {
return {
return uniqBy(
orderBy(
Object.values(fieldInstanceMap)
.map((field) => ({
...field,
order: viewColumnMeta?.[field.id]?.order ?? Number.MIN_SAFE_INTEGER,
};
}),
['order', 'createTime']
isStructuredCellValue: field.isStructuredCellValue,
}))
.filter((field) => {
if (!viewColumnMeta) {
return true;
}
return !viewColumnMeta?.[field.id]?.hidden;
})
.filter((field) => {
if (!projection) {
return true;
}
return projection.includes(field.id);
})
.filter((field) => {
if (!search?.[1]) {
return true;
}

const searchArr = search[1].split(',');
return searchArr.includes(field.id);
})
.filter((field) => {
if (field.dbFieldType === DbFieldType.Boolean) {
return false;
}
return true;
})
.map((field) => {
return {
...field,
order: viewColumnMeta?.[field.id]?.order ?? Number.MIN_SAFE_INTEGER,
};
}),
['order', 'createTime']
),
'id'
) as unknown as IFieldInstance[];
}

Expand Down

0 comments on commit e665a02

Please sign in to comment.