mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 22:38:56 +08:00
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:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user