feat(history): add query history filters
This commit is contained in:
1 parent
1c7576537a
commit
d16ba82d5a
22 files changed
+1324
-40
No files matched your search
@@ -486,6 +486,8 @@ async fn main() {
|
||||
// History
|
||||
.route("/history", get(routes::history::load_history).delete(routes::history::clear_history))
|
||||
.route("/history/save", post(routes::history::save_history))
|
||||
.route("/history/search", post(routes::history::search_history))
|
||||
.route("/history/options", get(routes::history::load_history_connection_options))
|
||||
.route("/history/{id}", delete(routes::history::delete_history_entry))
|
||||
// Saved SQL
|
||||
.route(
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::sync::Arc;
|
||||
|
||||
use axum::extract::{Path, Query, State};
|
||||
use axum::Json;
|
||||
use dbx_core::history::HistoryEntry;
|
||||
use dbx_core::history::{HistoryConnectionOption, HistoryEntry, HistorySearchRequest, HistorySearchResult};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::error::AppError;
|
||||
@@ -39,6 +39,19 @@ pub async fn load_history(
|
||||
Ok(Json(entries))
|
||||
}
|
||||
|
||||
pub async fn search_history(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Json(request): Json<HistorySearchRequest>,
|
||||
) -> Result<Json<HistorySearchResult>, AppError> {
|
||||
state.app.storage.search_history_entries(request).await.map(Json).map_err(AppError)
|
||||
}
|
||||
|
||||
pub async fn load_history_connection_options(
|
||||
State(state): State<Arc<WebState>>,
|
||||
) -> Result<Json<Vec<HistoryConnectionOption>>, AppError> {
|
||||
state.app.storage.load_history_connection_options().await.map(Json).map_err(AppError)
|
||||
}
|
||||
|
||||
pub async fn clear_history(State(state): State<Arc<WebState>>) -> Result<Json<()>, AppError> {
|
||||
state.app.storage.clear_history().await.map_err(AppError)?;
|
||||
Ok(Json(()))
|
||||
|
||||
Reference in new issue
Block a user