You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let db = db.lock().map_err(|_| actix_web::error::ErrorInternalServerError("Database lock failed"))?;
55
+
56
+
let cursor = query.get("cursor").cloned();
57
+
let limit:i32 = query
58
+
.get("limit")
59
+
.and_then(|s| s.parse().ok())
60
+
.unwrap_or(30);
61
+
62
+
let tasks:Vec<Task> = ifletSome(cursor_val) = cursor {
63
+
letmut stmt = db
64
+
.prepare("SELECT id, execution_date, webhook_name, executed_command, command_exit_code, command_stdout, command_stderr FROM logs_webhooks WHERE execution_date > ? ORDER BY execution_date DESC LIMIT ?")
65
+
.map_err(|_| actix_web::error::ErrorInternalServerError("Failed to prepare query"))?;
66
+
67
+
let rows = stmt.query_map(rusqlite::params![cursor_val, limit], |row| {
68
+
Ok(Task{
69
+
id: row.get(0)?,
70
+
execution_date: row.get(1)?,
71
+
webhook_name: row.get(2)?,
72
+
executed_command: row.get(3)?,
73
+
command_exit_code: row.get(4)?,
74
+
command_stdout: row.get(5)?,
75
+
command_stderr: row.get(6)?,
76
+
})
77
+
})
78
+
.map_err(|_| actix_web::error::ErrorInternalServerError("Failed to query tasks"))?;
79
+
80
+
rows.collect::<Result<Vec<_>,_>>()
81
+
.map_err(|_| actix_web::error::ErrorInternalServerError("Failed to collect tasks"))?
82
+
}else{
83
+
letmut stmt = db
84
+
.prepare("SELECT id, execution_date, webhook_name, executed_command, command_exit_code, command_stdout, command_stderr FROM logs_webhooks ORDER BY execution_date DESC LIMIT ?")
85
+
.map_err(|_| actix_web::error::ErrorInternalServerError("Failed to prepare query"))?;
86
+
87
+
let rows = stmt.query_map(rusqlite::params![limit], |row| {
88
+
Ok(Task{
89
+
id: row.get(0)?,
90
+
execution_date: row.get(1)?,
91
+
webhook_name: row.get(2)?,
92
+
executed_command: row.get(3)?,
93
+
command_exit_code: row.get(4)?,
94
+
command_stdout: row.get(5)?,
95
+
command_stderr: row.get(6)?,
96
+
})
97
+
})
98
+
.map_err(|_| actix_web::error::ErrorInternalServerError("Failed to query tasks"))?;
99
+
100
+
rows.collect::<Result<Vec<_>,_>>()
101
+
.map_err(|_| actix_web::error::ErrorInternalServerError("Failed to collect tasks"))?
0 commit comments