slopreporting

This commit is contained in:
legop3
2026-07-25 15:54:38 -04:00
parent 3a26b4871a
commit 8642fbac3c
21 changed files with 707 additions and 555 deletions
@@ -63,6 +63,12 @@ function createStorage({ logger }) {
gap_count INTEGER NOT NULL,
charged_mah REAL NOT NULL,
discharged_mah REAL NOT NULL,
charged_wh REAL NOT NULL DEFAULT 0,
discharged_wh REAL NOT NULL DEFAULT 0,
moving_discharged_wh REAL NOT NULL DEFAULT 0,
stationary_discharged_wh REAL NOT NULL DEFAULT 0,
moving_ms INTEGER NOT NULL DEFAULT 0,
maximum_speed_mm_per_second REAL,
min_voltage_mv INTEGER,
max_voltage_mv INTEGER,
avg_voltage_mv REAL,
@@ -152,6 +158,12 @@ function createStorage({ logger }) {
['wheel_drop_count', 'INTEGER NOT NULL DEFAULT 0'],
['virtual_wall_count', 'INTEGER NOT NULL DEFAULT 0'],
['overcurrent_episode_count', 'INTEGER NOT NULL DEFAULT 0'],
['charged_wh', 'REAL NOT NULL DEFAULT 0'],
['discharged_wh', 'REAL NOT NULL DEFAULT 0'],
['moving_discharged_wh', 'REAL NOT NULL DEFAULT 0'],
['stationary_discharged_wh', 'REAL NOT NULL DEFAULT 0'],
['moving_ms', 'INTEGER NOT NULL DEFAULT 0'],
['maximum_speed_mm_per_second', 'REAL'],
].forEach(([name, definition]) => {
if (!minuteColumns.has(name)) db.exec(`ALTER TABLE fleet_minute_samples ADD COLUMN ${name} ${definition}`);
});
@@ -165,6 +177,8 @@ function createStorage({ logger }) {
INSERT INTO fleet_minute_samples (
rover_id, bucket_ts, sample_count, coverage_ms, gap_count,
charged_mah, discharged_mah, min_voltage_mv, max_voltage_mv, avg_voltage_mv,
charged_wh, discharged_wh, moving_discharged_wh,
stationary_discharged_wh, moving_ms, maximum_speed_mm_per_second,
min_current_ma, max_current_ma, avg_current_ma, min_temperature_c,
max_temperature_c, avg_temperature_c, min_charge_mah, max_charge_mah,
last_charge_mah, reported_capacity_mah, docked_samples, charging_samples,
@@ -174,6 +188,8 @@ function createStorage({ logger }) {
) VALUES (
@roverId, @bucketTs, @sampleCount, @coverageMs, @gapCount,
@chargedMah, @dischargedMah, @minVoltageMv, @maxVoltageMv, @avgVoltageMv,
@chargedWh, @dischargedWh, @movingDischargedWh,
@stationaryDischargedWh, @movingMs, @maximumSpeedMmPerSecond,
@minCurrentMa, @maxCurrentMa, @avgCurrentMa, @minTemperatureC,
@maxTemperatureC, @avgTemperatureC, @minChargeMah, @maxChargeMah,
@lastChargeMah, @reportedCapacityMah, @dockedSamples, @chargingSamples,
@@ -187,6 +203,12 @@ function createStorage({ logger }) {
gap_count = excluded.gap_count,
charged_mah = excluded.charged_mah,
discharged_mah = excluded.discharged_mah,
charged_wh = excluded.charged_wh,
discharged_wh = excluded.discharged_wh,
moving_discharged_wh = excluded.moving_discharged_wh,
stationary_discharged_wh = excluded.stationary_discharged_wh,
moving_ms = excluded.moving_ms,
maximum_speed_mm_per_second = excluded.maximum_speed_mm_per_second,
min_voltage_mv = excluded.min_voltage_mv,
max_voltage_mv = excluded.max_voltage_mv,
avg_voltage_mv = excluded.avg_voltage_mv,
@@ -318,6 +340,11 @@ function createStorage({ logger }) {
SELECT rover_id AS roverId, bucket_ts AS bucketTs, sample_count AS sampleCount,
coverage_ms AS coverageMs, gap_count AS gapCount, charged_mah AS chargedMah,
discharged_mah AS dischargedMah, min_voltage_mv AS minVoltageMv,
charged_wh AS chargedWh, discharged_wh AS dischargedWh,
moving_discharged_wh AS movingDischargedWh,
stationary_discharged_wh AS stationaryDischargedWh,
moving_ms AS movingMs,
maximum_speed_mm_per_second AS maximumSpeedMmPerSecond,
max_voltage_mv AS maxVoltageMv, avg_voltage_mv AS avgVoltageMv,
min_current_ma AS minCurrentMa, max_current_ma AS maxCurrentMa,
avg_current_ma AS avgCurrentMa, min_temperature_c AS minTemperatureC,