feat(server): stats globais e rate limit por peer

This commit is contained in:
2026-08-05 20:53:36 -03:00
parent 45a4c1eceb
commit d9d7a25eca
8 changed files with 142 additions and 17 deletions
+8 -10
View File
@@ -87,22 +87,20 @@ pub fn search_files(
FROM files f",
);
let mut params: Vec<Box<dyn rusqlite::ToSql>> = Vec::new();
let mut where_added = false;
let mut clauses: Vec<String> = Vec::new();
if let Some(query) = crate::search::fts_query(q) {
sql.push_str(" JOIN files_fts ON files_fts.rowid = f.rowid WHERE files_fts MATCH ?1");
sql.push_str(" JOIN files_fts ON files_fts.rowid = f.rowid");
clauses.push("files_fts MATCH ?".to_string());
params.push(Box::new(query));
where_added = true;
}
if let Some(ft) = ftype {
if !where_added {
sql.push_str(" WHERE");
where_added = true;
} else {
sql.push_str(" AND");
}
params.push(Box::new(ft.to_string()));
sql.push_str(&format!(" f.ftype = ?{}", params.len()));
clauses.push(format!("f.ftype = ?{}", params.len()));
}
if !clauses.is_empty() {
sql.push_str(" WHERE ");
sql.push_str(&clauses.join(" AND "));
}
params.push(Box::new(limit));
sql.push_str(&format!(" ORDER BY f.created_at DESC LIMIT ?{}", params.len()));