This commit is contained in:
Stuart Axelbrooke 2025-11-22 21:55:55 +08:00
parent be2b15de5e
commit f14d93da7a
2 changed files with 6 additions and 14 deletions

View file

@ -69,11 +69,7 @@ impl BELStorage for MemoryBELStorage {
}
fn get_event(&self, event_id: u64) -> Result<Option<DataBuildEvent>, DatabuildError> {
Ok(self
.events
.iter()
.find(|e| e.event_id == event_id)
.cloned())
Ok(self.events.iter().find(|e| e.event_id == event_id).cloned())
}
fn latest_event_id(&self) -> Result<u64, DatabuildError> {
@ -190,9 +186,8 @@ impl BELStorage for SqliteBELStorage {
.lock()
.map_err(|e| format!("Failed to acquire lock: {}", e))?;
let mut stmt = connection.prepare(
"SELECT event_id, timestamp, event_data FROM events WHERE event_id = ?1",
)?;
let mut stmt = connection
.prepare("SELECT event_id, timestamp, event_data FROM events WHERE event_id = ?1")?;
let result = stmt.query_row([event_id], |row| {
let event_id: u64 = row.get(0)?;

View file

@ -7,16 +7,16 @@ use crate::{
ListWantsRequest, ListWantsResponse,
};
use axum::{
Json, Router,
extract::{Path, Query, Request, State},
http::StatusCode,
middleware::{self, Next},
response::{IntoResponse, Response},
routing::{delete, get, post},
Json, Router,
};
use std::sync::{
atomic::{AtomicU64, Ordering},
Arc,
atomic::{AtomicU64, Ordering},
};
use std::time::{SystemTime, UNIX_EPOCH};
use tokio::sync::{broadcast, mpsc, oneshot};
@ -131,10 +131,7 @@ async fn list_wants(
}
/// Get a specific want by ID
async fn get_want(
State(state): State<AppState>,
Path(want_id): Path<String>,
) -> impl IntoResponse {
async fn get_want(State(state): State<AppState>, Path(want_id): Path<String>) -> impl IntoResponse {
let events = match state.bel_storage.list_events(0, 100000) {
Ok(events) => events,
Err(e) => {