// Simple test for influx_sql.js functions import { fetchActData, fetchNoiseAVGData } from './databases/influx_sql.js' async function testInfluxSQL() { console.log('Testing InfluxDB 1.8 SQL implementation...') // Test options similar to what would be used in the application const testOpts = { sensorid: 'test_sensor_001', start: 'now() - 1h', stop: 'now()', sort: 1, peak: 70, // dB threshold for noise peaks long: false } try { console.log('\n1. Testing fetchActData...') const actResult = await fetchActData(testOpts) console.log('fetchActData result structure:', { err: actResult.err, valuesCount: actResult.values ? actResult.values.length : 0, sampleValue: actResult.values && actResult.values.length > 0 ? actResult.values[0] : null }) console.log('\n2. Testing fetchNoiseAVGData...') const noiseResult = await fetchNoiseAVGData(testOpts) console.log('fetchNoiseAVGData result structure:', { err: noiseResult.err, valuesCount: noiseResult.values ? noiseResult.values.length : 0, sampleValue: noiseResult.values && noiseResult.values.length > 0 ? noiseResult.values[0] : null }) console.log('\n3. Testing fetchNoiseAVGData with long format...') testOpts.long = true const noiseLongResult = await fetchNoiseAVGData(testOpts) console.log('fetchNoiseAVGData (long) result structure:', { err: noiseLongResult.err, valuesCount: noiseLongResult.values ? noiseLongResult.values.length : 0, sampleValue: noiseLongResult.values && noiseLongResult.values.length > 0 ? noiseLongResult.values[0] : null }) } catch (error) { console.error('Test error:', error) } } // Export for use in other test files export { testInfluxSQL } // Run test if this file is executed directly if (import.meta.url === `file://${process.argv[1]}`) { testInfluxSQL() }