feat: refactor parsing and scanning logic for test files

- Updated `parseFilename` to `parseTargetFilename` and modified its return structure to include `test_id` instead of `file_id`.
- Introduced `parseResultFilename` to extract `test_id` and `device` from result file names.
- Enhanced `fullScan` to separately handle target and results directories, improving clarity and functionality.
- Updated database interactions to use `test_id` instead of `file_id` across various modules.
- Added a new `/rescan` endpoint to trigger a full scan of target and results directories.
- Improved logging and error handling throughout the scanning process.
- Introduced `parseTputRssi` to extract throughput and RSSI data from log files.
This commit is contained in:
2026-05-21 14:53:08 -04:00
parent ed0f93036d
commit a67815c61a
22 changed files with 9791 additions and 228 deletions
+12 -7
View File
@@ -5,9 +5,9 @@ const cors = require('cors');
const path = require('path');
const fs = require('fs');
const { getConfig } = require('./db');
const { getConfig, countTests } = require('./db');
const { fullScan } = require('./scanner');
const { startWatching } = require('./watcher');
const { startWatching } = require('./watcher')
const app = express();
const PORT = process.env.PORT || 3001;
@@ -35,11 +35,16 @@ async function start() {
const resultsDir = getConfig('results_dir');
if (targetDir && resultsDir) {
console.log('[server] Scanning directories...');
await fullScan(targetDir, resultsDir);
const { getAllTests } = require('./db');
const tests = getAllTests();
console.log(`[server] Startup scan complete — ${tests.length} tests found, ${tests.filter(t => t.completed).length} completed`);
const existing = countTests();
if (existing > 0) {
console.log(`[server] Resuming from DB — ${existing} tests already loaded.`);
} else {
console.log('[server] No cached data, scanning directories...');
await fullScan(targetDir, resultsDir);
const { getAllTests } = require('./db');
const tests = getAllTests();
console.log(`[server] Scan complete — ${tests.length} tests found, ${tests.filter(t => t.completed).length} completed`);
}
startWatching(targetDir, resultsDir);
console.log('[server] Watching for changes.');
} else {