fix: 补齐投递记录时间筛选统计与分页
This commit is contained in:
+19
-2
@@ -151,6 +151,14 @@ const messages: MessageDetail[] = [
|
||||
pushed_at_ms: now() - 3_599_000,
|
||||
updated_at_ms: now() - 3_598_000,
|
||||
},
|
||||
{
|
||||
endpoint_id: "ops-bot",
|
||||
state: "rejected",
|
||||
reason: "disabled",
|
||||
attempts: 1,
|
||||
pushed_at_ms: now() - 3_599_000,
|
||||
updated_at_ms: now() - 3_598_000,
|
||||
},
|
||||
],
|
||||
next_cursor: "",
|
||||
},
|
||||
@@ -730,6 +738,8 @@ export const mockApi = {
|
||||
endpoint_id?: string;
|
||||
group_id?: string;
|
||||
state?: string;
|
||||
from_ms?: number;
|
||||
to_ms?: number;
|
||||
}): Promise<PageResult<MessageSummary>> {
|
||||
requireSession();
|
||||
let list = messages.map(toMessageSummary);
|
||||
@@ -742,16 +752,23 @@ export const mockApi = {
|
||||
});
|
||||
}
|
||||
if (q.state) list = list.filter((m) => m.state === q.state);
|
||||
if (q.from_ms != null) list = list.filter((m) => m.created_at_ms >= q.from_ms!);
|
||||
if (q.to_ms != null) list = list.filter((m) => m.created_at_ms <= q.to_ms!);
|
||||
return paginate(list, q.cursor, q.limit);
|
||||
},
|
||||
|
||||
async getMessage(seq: number): Promise<MessageDetail> {
|
||||
async getMessage(seq: number, cursor?: string, limit?: number): Promise<MessageDetail> {
|
||||
requireSession();
|
||||
const m = messages.find((x) => x.seq === seq);
|
||||
if (!m) {
|
||||
throw new ApiError("not_found", "消息不存在", 404);
|
||||
}
|
||||
return clone(m);
|
||||
const page = paginate(m.deliveries, cursor, limit ?? 200);
|
||||
return {
|
||||
...clone(m),
|
||||
deliveries: page.items,
|
||||
next_cursor: page.next_cursor,
|
||||
};
|
||||
},
|
||||
|
||||
async getSettings(): Promise<RuntimeSettings> {
|
||||
|
||||
Reference in New Issue
Block a user