Merge branch 'cw/radar' into cw-merge-1772825408137
This commit is contained in:
@@ -88,6 +88,24 @@ class InMemoryConversationRepository implements ConversationRepository {
|
||||
return updated;
|
||||
}
|
||||
|
||||
async countByFromAgentIds(agentIds: string[]): Promise<{ agentId: string; count: number }[]> {
|
||||
if (agentIds.length === 0) return [];
|
||||
const counts = new Map<string, number>();
|
||||
for (const conv of this.store.values()) {
|
||||
if (agentIds.includes(conv.fromAgentId)) {
|
||||
counts.set(conv.fromAgentId, (counts.get(conv.fromAgentId) ?? 0) + 1);
|
||||
}
|
||||
}
|
||||
return [...counts.entries()].map(([agentId, count]) => ({ agentId, count }));
|
||||
}
|
||||
|
||||
async findByFromAgentId(agentId: string): Promise<Conversation[]> {
|
||||
return [...this.store.values()]
|
||||
.filter((c) => c.fromAgentId === agentId)
|
||||
.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime())
|
||||
.slice(0, 200);
|
||||
}
|
||||
|
||||
/** Test helper — return all conversations */
|
||||
getAll(): Conversation[] {
|
||||
return [...this.store.values()];
|
||||
|
||||
Reference in New Issue
Block a user