Normalize research history API response
This commit is contained in:
@@ -15,9 +15,23 @@ export interface ResearchListItem extends ResearchSummary {
|
|||||||
|
|
||||||
const HISTORY_LIMIT = 50;
|
const HISTORY_LIMIT = 50;
|
||||||
|
|
||||||
|
interface ResearchListResponse {
|
||||||
|
items: Array<{
|
||||||
|
research_id: string;
|
||||||
|
query: string;
|
||||||
|
state: string;
|
||||||
|
created_at: string;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
export async function loadResearchHistory(apiKey: string): Promise<ResearchSummary[]> {
|
export async function loadResearchHistory(apiKey: string): Promise<ResearchSummary[]> {
|
||||||
const response = await apiGet<{ items: ResearchSummary[] }>('/v1/research', { apiKey });
|
const response = await apiGet<ResearchListResponse>('/v1/research', { apiKey });
|
||||||
const list = response.items;
|
const list = response.items.map(item => ({
|
||||||
|
id: item.research_id,
|
||||||
|
query: item.query,
|
||||||
|
status: item.state,
|
||||||
|
created_at: item.created_at,
|
||||||
|
}));
|
||||||
// Sort descending by created_at (newest first), limit to HISTORY_LIMIT
|
// Sort descending by created_at (newest first), limit to HISTORY_LIMIT
|
||||||
const sorted = list
|
const sorted = list
|
||||||
.slice()
|
.slice()
|
||||||
|
|||||||
Reference in New Issue
Block a user