Remote start stop control
This commit is contained in:
@@ -49,6 +49,13 @@ impl NodeDb {
|
||||
INSERT INTO _schema_version VALUES (3);
|
||||
");
|
||||
}
|
||||
if version < 4 {
|
||||
let _ = conn.execute_batch("
|
||||
ALTER TABLE node_sessions ADD COLUMN is_paused BOOLEAN DEFAULT 0;
|
||||
DELETE FROM _schema_version;
|
||||
INSERT INTO _schema_version VALUES (4);
|
||||
");
|
||||
}
|
||||
|
||||
conn.execute_batch("
|
||||
CREATE TABLE IF NOT EXISTS node_sessions (
|
||||
@@ -84,7 +91,10 @@ impl NodeDb {
|
||||
has_webgpu BOOLEAN,
|
||||
|
||||
-- Tehtävätilastot
|
||||
tasks_completed INTEGER DEFAULT 0
|
||||
tasks_completed INTEGER DEFAULT 0,
|
||||
|
||||
-- Ohjaustilat
|
||||
is_paused BOOLEAN DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pair_results (
|
||||
@@ -183,6 +193,14 @@ impl NodeDb {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn update_session_status(&self, node_id: u64, is_paused: bool) {
|
||||
let conn = self.conn.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let _ = conn.execute(
|
||||
"UPDATE node_sessions SET is_paused = ?1 WHERE node_id = ?2 AND disconnected_at IS NULL",
|
||||
params![is_paused as i64, node_id as i64],
|
||||
);
|
||||
}
|
||||
|
||||
/// Sulkee saman IP:n viewer-sessiot kun aktiivinen node liittyy
|
||||
pub fn close_viewers_by_ip(&self, ip: &str) {
|
||||
let conn = self.conn.lock().unwrap_or_else(|e| e.into_inner());
|
||||
@@ -216,7 +234,7 @@ impl NodeDb {
|
||||
"SELECT id, node_id, ip, node_type, connected_at, disconnected_at,
|
||||
platform, hostname, os, cpu_cores, cpu_model, ram_mb,
|
||||
gpu_name, gpu_vendor, gpu_backend, vram_total_mb, gpu_temp_c, gpu_util_pct,
|
||||
allocated_gb, selected_task, has_webgpu, tasks_completed
|
||||
allocated_gb, selected_task, has_webgpu, tasks_completed, is_paused
|
||||
FROM node_sessions ORDER BY id DESC LIMIT ?1"
|
||||
).unwrap();
|
||||
|
||||
@@ -244,6 +262,7 @@ impl NodeDb {
|
||||
"selected_task": row.get::<_, Option<String>>(19)?,
|
||||
"has_webgpu": row.get::<_, Option<bool>>(20)?,
|
||||
"tasks_completed": row.get::<_, i64>(21)?,
|
||||
"is_paused": row.get::<_, Option<bool>>(22)?.unwrap_or(false),
|
||||
}))
|
||||
}).unwrap().filter_map(|r| r.ok()).collect()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user