initial commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
// Check database for received data
|
||||
const db = require('./src/database/db');
|
||||
const { statsQueries, messageQueries, nodeQueries, positionQueries } = require('./src/database/queries');
|
||||
|
||||
console.log('\n=== Database Statistics ===\n');
|
||||
|
||||
try {
|
||||
const stats = {
|
||||
messages: statsQueries.getMessageCount.get(),
|
||||
nodes: statsQueries.getNodeCount.get(),
|
||||
positions: statsQueries.getPositionCount.get(),
|
||||
dbSize: statsQueries.getDbSize()
|
||||
};
|
||||
|
||||
console.log(`Messages: ${stats.messages.count}`);
|
||||
console.log(`Nodes: ${stats.nodes.count}`);
|
||||
console.log(`Positions: ${stats.positions.count}`);
|
||||
console.log(`DB Size: ${(stats.dbSize / 1024 / 1024).toFixed(2)} MB`);
|
||||
|
||||
if (stats.messages.count > 0) {
|
||||
console.log('\n=== Recent Messages ===\n');
|
||||
const messages = messageQueries.getRecentMessages.all(5);
|
||||
messages.forEach(msg => {
|
||||
console.log(`[${msg.created_at}] ${msg.from_node}: ${msg.text || '(no text)'}`);
|
||||
});
|
||||
}
|
||||
|
||||
if (stats.nodes.count > 0) {
|
||||
console.log('\n=== Nodes ===\n');
|
||||
const nodes = nodeQueries.getAllNodes.all();
|
||||
nodes.forEach(node => {
|
||||
console.log(`${node.node_id} - ${node.long_name || node.short_name || 'Unknown'} (${node.hardware_model || 'N/A'})`);
|
||||
});
|
||||
}
|
||||
|
||||
if (stats.positions.count > 0) {
|
||||
console.log('\n=== Recent Positions ===\n');
|
||||
const positions = positionQueries.getLatestPositions.all();
|
||||
positions.slice(0, 5).forEach(pos => {
|
||||
console.log(`${pos.node_id}: ${pos.latitude}, ${pos.longitude} @ ${pos.timestamp}`);
|
||||
});
|
||||
}
|
||||
|
||||
console.log('\n');
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
console.error('Error:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user