fix: limit comes after order by

This commit is contained in:
əlemi 2024-12-03 14:41:55 +01:00
parent 599358623e
commit 38c02a967c
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -67,7 +67,7 @@ impl Database {
pub async fn get(&self, sid: i64, limit: i64) -> rusqlite::Result<Vec<Event>> { pub async fn get(&self, sid: i64, limit: i64) -> rusqlite::Result<Vec<Event>> {
let db = self.0.lock().await; let db = self.0.lock().await;
let mut stmt = db.prepare("SELECT time, value FROM events WHERE service = :sid LIMIT :limit ORDER BY time DESC")?; let mut stmt = db.prepare("SELECT time, value FROM events WHERE service = :sid ORDER BY time DESC LIMIT :limit")?;
let results = stmt.query_map( let results = stmt.query_map(
named_params! { ":sid": sid, ":limit": limit }, named_params! { ":sid": sid, ":limit": limit },
|row| Ok((row.get(0)?, row.get(1)?)), |row| Ok((row.get(0)?, row.get(1)?)),