feat(server): get recently updated docs (#12861)

close AI-218



#### PR Dependency Tree


* **PR #12861** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

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

- **New Features**
- Added a "Recently Updated Documents" feature, allowing users to view a
paginated list of the most recently updated documents within a
workspace.
- Document metadata now includes a "title" field for easier
identification.
- **Tests**
- Introduced new end-to-end tests to verify the recently updated
documents query and its pagination behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
fengmk2
2025-06-20 11:35:39 +08:00
committed by GitHub
parent 5623d808bf
commit ad5722f637
7 changed files with 237 additions and 0 deletions

View File

@@ -76,6 +76,9 @@ class DocType {
@Field(() => String, { nullable: true })
lastUpdaterId?: string;
@Field(() => String, { nullable: true })
title?: string | null;
}
@InputType()
@@ -266,6 +269,26 @@ export class WorkspaceDocResolver {
return paginate(rows, 'createdAt', pagination, count);
}
@ResolveField(() => PaginatedDocType, {
description: 'Get recently updated docs of a workspace',
})
async recentlyUpdatedDocs(
@CurrentUser() me: CurrentUser,
@Parent() workspace: WorkspaceType,
@Args('pagination', PaginationInput.decode) pagination: PaginationInput
): Promise<PaginatedDocType> {
const [count, rows] = await this.models.doc.paginateDocInfoByUpdatedAt(
workspace.id,
pagination
);
const needs = await this.ac
.user(me.id)
.workspace(workspace.id)
.docs(rows, 'Doc.Read');
return paginate(needs, 'updatedAt', pagination, count);
}
@ResolveField(() => DocType, {
description: 'Get get with given id',
complexity: 2,