fmt
This commit is contained in:
parent
be2b15de5e
commit
f14d93da7a
2 changed files with 6 additions and 14 deletions
|
|
@ -69,11 +69,7 @@ impl BELStorage for MemoryBELStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_event(&self, event_id: u64) -> Result<Option<DataBuildEvent>, DatabuildError> {
|
fn get_event(&self, event_id: u64) -> Result<Option<DataBuildEvent>, DatabuildError> {
|
||||||
Ok(self
|
Ok(self.events.iter().find(|e| e.event_id == event_id).cloned())
|
||||||
.events
|
|
||||||
.iter()
|
|
||||||
.find(|e| e.event_id == event_id)
|
|
||||||
.cloned())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn latest_event_id(&self) -> Result<u64, DatabuildError> {
|
fn latest_event_id(&self) -> Result<u64, DatabuildError> {
|
||||||
|
|
@ -190,9 +186,8 @@ impl BELStorage for SqliteBELStorage {
|
||||||
.lock()
|
.lock()
|
||||||
.map_err(|e| format!("Failed to acquire lock: {}", e))?;
|
.map_err(|e| format!("Failed to acquire lock: {}", e))?;
|
||||||
|
|
||||||
let mut stmt = connection.prepare(
|
let mut stmt = connection
|
||||||
"SELECT event_id, timestamp, event_data FROM events WHERE event_id = ?1",
|
.prepare("SELECT event_id, timestamp, event_data FROM events WHERE event_id = ?1")?;
|
||||||
)?;
|
|
||||||
|
|
||||||
let result = stmt.query_row([event_id], |row| {
|
let result = stmt.query_row([event_id], |row| {
|
||||||
let event_id: u64 = row.get(0)?;
|
let event_id: u64 = row.get(0)?;
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,16 @@ use crate::{
|
||||||
ListWantsRequest, ListWantsResponse,
|
ListWantsRequest, ListWantsResponse,
|
||||||
};
|
};
|
||||||
use axum::{
|
use axum::{
|
||||||
|
Json, Router,
|
||||||
extract::{Path, Query, Request, State},
|
extract::{Path, Query, Request, State},
|
||||||
http::StatusCode,
|
http::StatusCode,
|
||||||
middleware::{self, Next},
|
middleware::{self, Next},
|
||||||
response::{IntoResponse, Response},
|
response::{IntoResponse, Response},
|
||||||
routing::{delete, get, post},
|
routing::{delete, get, post},
|
||||||
Json, Router,
|
|
||||||
};
|
};
|
||||||
use std::sync::{
|
use std::sync::{
|
||||||
atomic::{AtomicU64, Ordering},
|
|
||||||
Arc,
|
Arc,
|
||||||
|
atomic::{AtomicU64, Ordering},
|
||||||
};
|
};
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
use tokio::sync::{broadcast, mpsc, oneshot};
|
use tokio::sync::{broadcast, mpsc, oneshot};
|
||||||
|
|
@ -131,10 +131,7 @@ async fn list_wants(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a specific want by ID
|
/// Get a specific want by ID
|
||||||
async fn get_want(
|
async fn get_want(State(state): State<AppState>, Path(want_id): Path<String>) -> impl IntoResponse {
|
||||||
State(state): State<AppState>,
|
|
||||||
Path(want_id): Path<String>,
|
|
||||||
) -> impl IntoResponse {
|
|
||||||
let events = match state.bel_storage.list_events(0, 100000) {
|
let events = match state.bel_storage.list_events(0, 100000) {
|
||||||
Ok(events) => events,
|
Ok(events) => events,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue