fix: add missing /api/admin/learning/knowledge-bases endpoint
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 45s
Dashboard filter dropdown calls this to populate KB selector. Returns knowledge bases that have reading event data with real titles. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
c0a8f7ef27
commit
c3fd6a221f
@ -16,6 +16,10 @@ export class AdminLearningController {
|
|||||||
@Query('endDate') endDate?: string,
|
@Query('endDate') endDate?: string,
|
||||||
) { return this.service.getDashboard({ knowledgeBaseId, startDate, endDate }); }
|
) { return this.service.getDashboard({ knowledgeBaseId, startDate, endDate }); }
|
||||||
|
|
||||||
|
// ── Knowledge Bases ──
|
||||||
|
@Get('knowledge-bases')
|
||||||
|
async getKnowledgeBases() { return this.service.getKnowledgeBases(); }
|
||||||
|
|
||||||
// ── ReadingEvents ──
|
// ── ReadingEvents ──
|
||||||
@Get('reading-events')
|
@Get('reading-events')
|
||||||
async getReadingEvents(@Query() query: EventFilterQuery) { return this.service.getReadingEvents(query); }
|
async getReadingEvents(@Query() query: EventFilterQuery) { return this.service.getReadingEvents(query); }
|
||||||
|
|||||||
@ -9,6 +9,28 @@ export class AdminLearningService {
|
|||||||
private readonly snapshotBuilder: SnapshotBuilderService,
|
private readonly snapshotBuilder: SnapshotBuilderService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
// ══ Knowledge Bases (for filter dropdown) ══
|
||||||
|
|
||||||
|
async getKnowledgeBases() {
|
||||||
|
// Return knowledge bases that appear in reading_events, with real names from KB table
|
||||||
|
const ids = await this.prisma.readingEvent.findMany({
|
||||||
|
where: { knowledgeBaseId: { not: null } },
|
||||||
|
select: { knowledgeBaseId: true },
|
||||||
|
distinct: ['knowledgeBaseId'],
|
||||||
|
take: 200,
|
||||||
|
});
|
||||||
|
const kbIds = [...new Set(ids.map(r => r.knowledgeBaseId!).filter(Boolean))];
|
||||||
|
|
||||||
|
if (kbIds.length === 0) return [];
|
||||||
|
|
||||||
|
const kbs = await this.prisma.knowledgeBase.findMany({
|
||||||
|
where: { id: { in: kbIds } },
|
||||||
|
select: { id: true, title: true },
|
||||||
|
take: 200,
|
||||||
|
});
|
||||||
|
return kbs.map(kb => ({ id: kb.id, name: kb.title }));
|
||||||
|
}
|
||||||
|
|
||||||
// ══ Dashboard ══
|
// ══ Dashboard ══
|
||||||
|
|
||||||
async getDashboard(filters?: { knowledgeBaseId?: string; startDate?: string; endDate?: string }) {
|
async getDashboard(filters?: { knowledgeBaseId?: string; startDate?: string; endDate?: string }) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user