chore(server): improve ignored docs list & match (#12307)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Bug Fixes**
	- Improved the accuracy of document matching by excluding ignored documents from search results.
- **Chores**
	- Updated internal handling of ignored document lists for better consistency and reliability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
darkskygit
2025-05-15 09:36:28 +00:00
parent 393458871d
commit 6224344a4f
5 changed files with 25 additions and 26 deletions
@@ -16,7 +16,6 @@ import type {
@Injectable()
export class CopilotWorkspaceConfigModel extends BaseModel {
@Transactional()
private async listIgnoredDocIds(
workspaceId: string,
options?: PaginationInput
@@ -47,16 +46,15 @@ export class CopilotWorkspaceConfigModel extends BaseModel {
);
const added = add.filter(id => !ignored.has(id));
if (added.length) {
const { count: addedCount } =
await this.db.aiWorkspaceIgnoredDocs.createMany({
data: added.map(docId => ({
workspaceId,
docId,
})),
});
}
if (removed.size) {
const { count: removedCount } =
await this.db.aiWorkspaceIgnoredDocs.deleteMany({
where: {
workspaceId,
@@ -65,11 +63,11 @@ export class CopilotWorkspaceConfigModel extends BaseModel {
},
},
});
}
return added.length + ignored.size;
return addedCount + removedCount;
}
@Transactional()
async listIgnoredDocs(
workspaceId: string,
options?: PaginationInput
@@ -100,6 +98,7 @@ export class CopilotWorkspaceConfigModel extends BaseModel {
});
}
@Transactional()
async countIgnoredDocs(workspaceId: string): Promise<number> {
const count = await this.db.aiWorkspaceIgnoredDocs.count({
where: {