169 async getMetricsHistory(hours: number): Promise<SystemMetrics[]> {
170 // For now, return current metrics as a single point
171 // In a real system, this would fetch historical data
172 const current = await this.getCurrentMetrics();
173 return [current];
103
104 try {
105 // Fetch events for this window
106 const events = await this.eventStorage.getEventsByTimeRange(windowStart, windowEnd);
107
29 return c.json(history);
30 } catch (error) {
31 console.error('Error fetching history:', error);
32 return c.json({ error: 'Failed to fetch history' }, 500);
33 }
34});
60 };
61
62 const response = await fetch('/api/gemini/generate', {
63 method: 'POST',
64 headers: {
34 };
35
36 const response = await fetch('/api/gemini/generate', {
37 method: 'POST',
38 headers: {
36 };
37
38 const response = await fetch('/api/gemini/generate', {
39 method: 'POST',
40 headers: {
33 };
34
35 const response = await fetch('/api/gemini/generate', {
36 method: 'POST',
37 headers: {
55 const loadHistory = async () => {
56 try {
57 const response = await fetch('/api/history');
58 if (response.ok) {
59 const historyData = await response.json();
88 const deleteFromHistory = async (id: string) => {
89 try {
90 const response = await fetch(`/api/history/${id}`, { method: 'DELETE' });
91 if (response.ok) {
92 setHistory(prev => prev.filter(item => item.id !== id));
103 const clearAllHistory = async () => {
104 try {
105 const response = await fetch('/api/history', { method: 'DELETE' });
106 if (response.ok) {
107 setHistory([]);
63 }
64
65 const response = await fetch(
66 `https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=${GEMINI_API_KEY}`,
67 {
44
45 try {
46 const response = await fetch(`/api/payments/bill/${bill.id}`, {
47 method: 'POST',
48 headers: {