mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-22 17:00:14 +08:00
feat: 更新会话列表查询,按更新时间降序排序
This commit is contained in:
parent
ede2b75cd0
commit
a0193451a9
@ -8,7 +8,7 @@ import {
|
|||||||
type UpdateSessionRequest,
|
type UpdateSessionRequest,
|
||||||
UpdateSessionResponse
|
UpdateSessionResponse
|
||||||
} from '@types'
|
} from '@types'
|
||||||
import { and, count, eq, type SQL } from 'drizzle-orm'
|
import { and, count, desc, eq, type SQL } from 'drizzle-orm'
|
||||||
|
|
||||||
import { BaseService } from '../BaseService'
|
import { BaseService } from '../BaseService'
|
||||||
import { agentsTable, type InsertSessionRow, type SessionRow, sessionsTable } from '../database/schema'
|
import { agentsTable, type InsertSessionRow, type SessionRow, sessionsTable } from '../database/schema'
|
||||||
@ -137,8 +137,12 @@ export class SessionService extends BaseService {
|
|||||||
|
|
||||||
const total = totalResult[0].count
|
const total = totalResult[0].count
|
||||||
|
|
||||||
// Build list query with pagination
|
// Build list query with pagination - sort by updated_at descending (latest first)
|
||||||
const baseQuery = this.database.select().from(sessionsTable).where(whereClause).orderBy(sessionsTable.created_at)
|
const baseQuery = this.database
|
||||||
|
.select()
|
||||||
|
.from(sessionsTable)
|
||||||
|
.where(whereClause)
|
||||||
|
.orderBy(desc(sessionsTable.updated_at))
|
||||||
|
|
||||||
const result =
|
const result =
|
||||||
options.limit !== undefined
|
options.limit !== undefined
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user