Dieser Commit ist enthalten in:
hendrik_gebhardt@gmx.de
2026-01-10 10:32:52 +00:00
committet von Server Deploy
Ursprung 7d67557be4
Commit ef153789cc
20 geänderte Dateien mit 13613 neuen und 333 gelöschten Zeilen

Datei anzeigen

@ -596,6 +596,23 @@ function createTables() {
logger.info('Migration: claude_instructions Spalte zu coding_directories hinzugefuegt');
}
// Coding Verbrauchsdaten
db.exec(`
CREATE TABLE IF NOT EXISTS coding_usage (
id INTEGER PRIMARY KEY AUTOINCREMENT,
directory_id INTEGER NOT NULL,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
cpu_percent REAL,
memory_mb REAL,
disk_read_mb REAL,
disk_write_mb REAL,
network_recv_mb REAL,
network_sent_mb REAL,
process_count INTEGER,
FOREIGN KEY (directory_id) REFERENCES coding_directories(id) ON DELETE CASCADE
)
`);
// Kontakte
db.exec(`
CREATE TABLE IF NOT EXISTS contacts (
@ -641,6 +658,8 @@ function createTables() {
CREATE INDEX IF NOT EXISTS idx_knowledge_entries_category ON knowledge_entries(category_id);
CREATE INDEX IF NOT EXISTS idx_knowledge_attachments_entry ON knowledge_attachments(entry_id);
CREATE INDEX IF NOT EXISTS idx_coding_directories_position ON coding_directories(position);
CREATE INDEX IF NOT EXISTS idx_coding_usage_directory ON coding_usage(directory_id);
CREATE INDEX IF NOT EXISTS idx_coding_usage_timestamp ON coding_usage(timestamp);
CREATE INDEX IF NOT EXISTS idx_contacts_company ON contacts(company);
CREATE INDEX IF NOT EXISTS idx_contacts_tags ON contacts(tags);
`);

Datei anzeigen

@ -640,4 +640,75 @@ router.get('/directories/:id/commits', (req, res) => {
}
});
/**
* GET /api/coding/directories/:id/usage
* Aktuelle Verbrauchsdaten abrufen (simuliert)
*/
router.get('/directories/:id/usage', (req, res) => {
try {
const { id } = req.params;
const db = getDb();
const directory = db.prepare('SELECT * FROM coding_directories WHERE id = ?').get(id);
if (!directory) {
return res.status(404).json({ error: 'Anwendung nicht gefunden' });
}
// Simulierte Verbrauchsdaten generieren
const usage = {
cpu_percent: Math.random() * 100,
memory_mb: Math.floor(Math.random() * 4096),
disk_read_mb: Math.random() * 100,
disk_write_mb: Math.random() * 50,
network_recv_mb: Math.random() * 10,
network_sent_mb: Math.random() * 10,
process_count: Math.floor(Math.random() * 20) + 1,
timestamp: new Date()
};
// Speichere in Datenbank für Historie
db.prepare(`
INSERT INTO coding_usage (directory_id, cpu_percent, memory_mb, disk_read_mb,
disk_write_mb, network_recv_mb, network_sent_mb, process_count)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
`).run(id, usage.cpu_percent, usage.memory_mb, usage.disk_read_mb,
usage.disk_write_mb, usage.network_recv_mb, usage.network_sent_mb, usage.process_count);
res.json({ usage });
} catch (error) {
logger.error('Fehler beim Abrufen der Verbrauchsdaten:', error);
res.status(500).json({ error: 'Interner Serverfehler' });
}
});
/**
* GET /api/coding/directories/:id/usage/history
* Historische Verbrauchsdaten abrufen
*/
router.get('/directories/:id/usage/history', (req, res) => {
try {
const { id } = req.params;
const hours = parseInt(req.query.hours) || 24;
const db = getDb();
const directory = db.prepare('SELECT * FROM coding_directories WHERE id = ?').get(id);
if (!directory) {
return res.status(404).json({ error: 'Anwendung nicht gefunden' });
}
const history = db.prepare(`
SELECT * FROM coding_usage
WHERE directory_id = ?
AND timestamp > datetime('now', '-${hours} hours')
ORDER BY timestamp DESC
LIMIT 100
`).all(id);
res.json({ history });
} catch (error) {
logger.error('Fehler beim Abrufen der Verbrauchshistorie:', error);
res.status(500).json({ error: 'Interner Serverfehler' });
}
});
module.exports = router;

Datei anzeigen

@ -753,7 +753,7 @@ router.get('/attachments/:entryId', (req, res) => {
* POST /api/knowledge/attachments/:entryId
* Anhang hochladen
*/
router.post('/attachments/:entryId', upload.single('file'), (req, res) => {
router.post('/attachments/:entryId', upload.single('files'), (req, res) => {
try {
const entryId = req.params.entryId;
const db = getDb();