mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 04:26:23 +08:00
feat(server): add doc meta for ignored docs (#12021)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Ignored documents in workspace embedding now display additional metadata, including document title, creation and update timestamps, and the names and avatars of users who created or updated the document. - **Enhancements** - The list of ignored documents provides richer information for easier identification and management within the workspace. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -11,6 +11,7 @@ import type {
|
||||
CopilotWorkspaceFileMetadata,
|
||||
Embedding,
|
||||
FileChunkSimilarity,
|
||||
IgnoredDoc,
|
||||
} from './common';
|
||||
|
||||
@Injectable()
|
||||
@@ -50,12 +51,13 @@ export class CopilotWorkspaceConfigModel extends BaseModel {
|
||||
return added.length + ignored.size;
|
||||
}
|
||||
|
||||
@Transactional()
|
||||
async listIgnoredDocs(
|
||||
workspaceId: string,
|
||||
options?: {
|
||||
includeRead?: boolean;
|
||||
} & PaginationInput
|
||||
): Promise<{ docId: string; createdAt: Date }[]> {
|
||||
): Promise<IgnoredDoc[]> {
|
||||
const row = await this.db.aiWorkspaceIgnoredDocs.findMany({
|
||||
where: {
|
||||
workspaceId,
|
||||
@@ -68,7 +70,29 @@ export class CopilotWorkspaceConfigModel extends BaseModel {
|
||||
skip: options?.offset,
|
||||
take: options?.first,
|
||||
});
|
||||
return row;
|
||||
const ids = row.map(r => ({ workspaceId, docId: r.docId }));
|
||||
const docs = await this.models.doc.findMetas(ids);
|
||||
const docsMap = new Map(
|
||||
docs.filter(r => !!r).map(r => [`${r.workspaceId}-${r.docId}`, r])
|
||||
);
|
||||
const authors = await this.models.doc.findAuthors(ids);
|
||||
const authorsMap = new Map(
|
||||
authors.filter(r => !!r).map(r => [`${r.workspaceId}-${r.id}`, r])
|
||||
);
|
||||
|
||||
return row.map(r => {
|
||||
const docMeta = docsMap.get(`${workspaceId}-${r.docId}`);
|
||||
const docAuthor = authorsMap.get(`${workspaceId}-${r.docId}`);
|
||||
return {
|
||||
...r,
|
||||
docCreatedAt: docAuthor?.createdAt,
|
||||
docUpdatedAt: docAuthor?.updatedAt,
|
||||
title: docMeta?.title || undefined,
|
||||
createdBy: docAuthor?.createdByUser?.name,
|
||||
createdByAvatar: docAuthor?.createdByUser?.avatarUrl || undefined,
|
||||
updatedBy: docAuthor?.updatedByUser?.name,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async countIgnoredDocs(workspaceId: string): Promise<number> {
|
||||
|
||||
Reference in New Issue
Block a user