feat(server): add generate title cron resolver (#13189)

fix AI-350

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

* **New Features**
* Added a new option to manually trigger the generation of missing
session titles via a GraphQL query.

* **Improvements**
* The process for generating missing session titles now considers all
eligible sessions, without limiting the number processed at a time.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
DarkSky
2025-07-14 17:19:21 +08:00
committed by GitHub
parent 7b53641a94
commit 9a3e44c6d6
6 changed files with 25 additions and 12 deletions
@@ -613,7 +613,7 @@ export class CopilotSessionModel extends BaseModel {
}
@Transactional()
async toBeGenerateTitle(take: number) {
async toBeGenerateTitle() {
const sessions = await this.db.aiSession
.findMany({
where: {
@@ -628,7 +628,6 @@ export class CopilotSessionModel extends BaseModel {
// count assistant messages
_count: { select: { messages: { where: { role: 'assistant' } } } },
},
take,
orderBy: { updatedAt: 'desc' },
})
.then(s => s.filter(s => s._count.messages > 0));