fix(server): resolve import issues

This commit is contained in:
perf3ct 2025-07-03 23:58:11 +00:00
parent f862df9a90
commit 0e84993afa
22 changed files with 19 additions and 1228 deletions

View File

@ -1,4 +1,3 @@
use anyhow::Result;
use sqlx::{Row, QueryBuilder, Postgres};
use uuid::Uuid;

View File

@ -63,6 +63,7 @@ impl Database {
created_at: row.get("created_at"),
updated_at: row.get("updated_at"),
document_count: 0,
source_count: 0,
};
if Some(doc_id) != current_doc_id {

View File

@ -1,5 +1,5 @@
use anyhow::Result;
use sqlx::{QueryBuilder, Postgres, Transaction};
use sqlx::{QueryBuilder, Postgres, Row};
use uuid::Uuid;
use crate::models::{Document, UserRole, FailedDocument};

View File

@ -9,7 +9,6 @@
use uuid::Uuid;
use sha2::{Digest, Sha256};
use tracing::{debug, info, warn};
use chrono::Utc;
use serde_json;
use crate::models::{Document, FileInfo};

View File

@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};
use utoipa::{ToSchema, IntoParams};
use super::responses::{EnhancedDocumentResponse, SearchSnippet, HighlightRange};
use super::responses::EnhancedDocumentResponse;
#[derive(Debug, Serialize, Deserialize, ToSchema, IntoParams)]
pub struct SearchRequest {

View File

@ -8,7 +8,7 @@
use std::sync::Arc;
use tokio::sync::Semaphore;
use tokio::time::{Duration, Instant};
use tracing::{warn, info};
use tracing::info;
/// Request throttler to limit concurrent operations
#[derive(Clone)]

View File

@ -1,62 +0,0 @@
use axum::{
routing::{get, post, delete},
Router,
};
use std::sync::Arc;
use crate::AppState;
// Import all the modularized functions
mod types;
mod crud;
mod ocr;
mod bulk;
mod debug;
mod failed;
// Re-export types for external use
pub use types::*;
// Use the individual module functions
use crud::*;
use ocr::*;
use bulk::*;
use debug::*;
use failed::*;
/// Documents router with all document-related endpoints
pub fn router() -> Router<Arc<AppState>> {
Router::new()
// Basic CRUD operations
.route("/", post(upload_document))
.route("/", get(list_documents))
.route("/", delete(bulk_delete_documents))
.route("/{id}", get(get_document_by_id))
.route("/{id}", delete(delete_document))
.route("/{id}/download", get(download_document))
.route("/{id}/view", get(view_document))
// OCR operations
.route("/{id}/ocr", get(get_document_ocr))
.route("/{id}/retry-ocr", post(retry_ocr))
.route("/ocr/bulk-retry", post(crate::routes::documents_ocr_retry::bulk_retry_ocr))
.route("/ocr/retry-stats", get(crate::routes::documents_ocr_retry::get_ocr_retry_stats))
.route("/ocr/retry-recommendations", get(crate::routes::documents_ocr_retry::get_retry_recommendations))
.route("/{id}/ocr/retry-history", get(crate::routes::documents_ocr_retry::get_document_retry_history))
// Bulk operations
.route("/delete-low-confidence", post(delete_low_confidence_documents))
.route("/delete-failed-ocr", post(delete_failed_ocr_documents))
// Debug and diagnostic operations
.route("/{id}/debug", get(get_document_debug_info))
.route("/{id}/thumbnail", get(get_document_thumbnail))
.route("/{id}/processed-image", get(get_processed_image))
// Failed document management
.route("/failed", get(get_failed_documents))
.route("/failed/{id}/view", get(view_failed_document))
// Other operations
.route("/duplicates", get(get_user_duplicates))
}

View File

@ -2,7 +2,7 @@ use axum::{
extract::State,
http::StatusCode,
response::Json,
routing::{get, put},
routing::get,
Router,
};
use std::sync::Arc;

View File

@ -1,41 +0,0 @@
use axum::{
routing::{get, post, delete, put},
Router,
};
use std::sync::Arc;
use crate::AppState;
// Declare the modules
mod crud;
mod sync;
mod validation;
mod estimation;
// Import all the modularized functions
use crud::*;
use sync::*;
use validation::*;
use estimation::*;
/// Sources router with all source-related endpoints
pub fn router() -> Router<Arc<AppState>> {
Router::new()
// Basic CRUD operations
.route("/", get(list_sources).post(create_source))
.route("/{id}", get(get_source).put(update_source).delete(delete_source))
// Sync operations
.route("/{id}/sync", post(trigger_sync))
.route("/{id}/sync/stop", post(stop_sync))
.route("/{id}/deep-scan", post(trigger_deep_scan))
// Validation and testing
.route("/{id}/validate", post(validate_source))
.route("/{id}/test", post(test_connection))
.route("/test-connection", post(test_connection_with_config))
// Estimation
.route("/{id}/estimate", post(estimate_crawl))
.route("/estimate", post(estimate_crawl_with_config))
}

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@ use axum::{
extract::{Path, State},
http::StatusCode,
response::Json,
routing::{get, post, put, delete},
routing::get,
Router,
};
use std::sync::Arc;

View File

@ -2,7 +2,7 @@ use std::sync::Arc;
use std::time::Duration;
use std::collections::HashMap;
use tokio::time::interval;
use tokio::sync::{Mutex, RwLock};
use tokio::sync::RwLock;
use tokio_util::sync::CancellationToken;
use tracing::{error, info, warn};
use chrono::Utc;

View File

@ -1,11 +1,10 @@
use std::sync::Arc;
use std::path::Path;
use anyhow::{anyhow, Result};
use chrono::Utc;
use tokio::sync::Semaphore;
use tokio_util::sync::CancellationToken;
use futures::stream::{FuturesUnordered, StreamExt};
use tracing::{debug, error, info, warn};
use tracing::{debug, error, info};
use uuid::Uuid;
use crate::{

View File

@ -5,8 +5,6 @@ use tracing::{error, info, warn};
use crate::{
db::Database,
ocr::queue::OcrQueueService,
services::file_service::FileService,
AppState,
};
use crate::services::webdav::{WebDAVConfig, WebDAVService};

View File

@ -1,7 +1,6 @@
use anyhow::Result;
use chrono::Utc;
use std::path::{Path, PathBuf};
use std::panic::{catch_unwind, AssertUnwindSafe};
use tokio::fs;
use uuid::Uuid;
use tracing::{info, warn, error};
@ -9,7 +8,7 @@ use tracing::{info, warn, error};
use crate::models::Document;
#[cfg(feature = "ocr")]
use image::{DynamicImage, ImageFormat, imageops::FilterType, Rgb, RgbImage, Rgba, ImageBuffer};
use image::{DynamicImage, ImageFormat, imageops::FilterType};
#[derive(Clone)]
pub struct FileService {

View File

@ -1,7 +1,7 @@
use std::path::Path;
use std::fs;
use anyhow::{anyhow, Result};
use chrono::{DateTime, Utc};
use chrono::DateTime;
use tracing::{debug, info, warn};
use walkdir::WalkDir;
use sha2::{Sha256, Digest};

View File

@ -1,12 +1,12 @@
use anyhow::{anyhow, Result};
use chrono::{DateTime, Utc};
use tracing::{debug, error, info, warn};
use chrono::DateTime;
use tracing::{debug, info, warn};
use serde_json;
#[cfg(feature = "s3")]
use aws_sdk_s3::Client;
#[cfg(feature = "s3")]
use aws_config::{BehaviorVersion, load_from_env};
use aws_config::load_from_env;
#[cfg(feature = "s3")]
use aws_credential_types::Credentials;
#[cfg(feature = "s3")]

View File

@ -1,4 +1,3 @@
use serde::{Deserialize, Serialize};
/// WebDAV server configuration
#[derive(Debug, Clone)]

View File

@ -1,9 +1,9 @@
use anyhow::{anyhow, Result};
use anyhow::Result;
use reqwest::Method;
use std::collections::HashSet;
use tokio::sync::Semaphore;
use futures_util::stream::{self, StreamExt};
use tracing::{debug, error, info, warn};
use tracing::{debug, info, warn};
use crate::models::{FileInfo, WebDAVCrawlEstimate, WebDAVFolderInfo};
use crate::webdav_xml_parser::{parse_propfind_response, parse_propfind_response_with_directories};

View File

@ -1,7 +1,7 @@
use anyhow::{anyhow, Result};
use std::sync::Arc;
use tokio::sync::Semaphore;
use tracing::{debug, error, info, warn};
use tracing::{debug, error, info};
use crate::models::{
FileInfo, WebDAVConnectionResult, WebDAVCrawlEstimate, WebDAVTestConnection,

View File

@ -1,7 +1,7 @@
use anyhow::{anyhow, Result};
use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use tracing::{debug, error, info, warn};
use tracing::{debug, info, warn};
use super::config::WebDAVConfig;
use super::connection::WebDAVConnection;

View File

@ -1,5 +1,5 @@
use std::env;
use tracing::{debug, info, warn, error};
use tracing::{info, warn, error};
/// Check if DEBUG environment variable is set to enable verbose debug output
pub fn is_debug_enabled() -> bool {