mirror of
https://github.com/perstarkse/minne.git
synced 2026-03-22 09:29:51 +01:00
chore: clippy fixes
This commit is contained in:
@@ -150,13 +150,8 @@ pub async fn get_task_updates_stream(
|
||||
let db = state.db.clone();
|
||||
|
||||
// 1. Check for authenticated user
|
||||
let current_user = match auth.current_user {
|
||||
Some(user) => user,
|
||||
None => {
|
||||
return Sse::new(create_error_stream(
|
||||
"User not authenticated. Please log in.",
|
||||
));
|
||||
}
|
||||
let Some(current_user) = auth.current_user else {
|
||||
return Sse::new(create_error_stream("User not authenticated"));
|
||||
};
|
||||
|
||||
// 2. Fetch task for initial authorization and to ensure it exists
|
||||
@@ -236,10 +231,10 @@ pub async fn get_task_updates_stream(
|
||||
Err(db_err) => {
|
||||
error!("Database error while fetching task '{}': {:?}", task_id, db_err);
|
||||
consecutive_db_errors += 1;
|
||||
yield Ok(Event::default().event("error").data(format!("Temporary error fetching task update (attempt {}).", consecutive_db_errors)));
|
||||
yield Ok(Event::default().event("error").data(format!("Temporary error fetching task update (attempt {consecutive_db_errors}).")));
|
||||
|
||||
if consecutive_db_errors >= max_consecutive_db_errors {
|
||||
error!("Max consecutive DB errors reached for task '{}'. Closing stream.", task_id);
|
||||
error!("Max consecutive DB errors reached for task '{task_id}'. Closing stream.");
|
||||
yield Ok(Event::default().event("error").data("Persistent error fetching task updates. Stream closed."));
|
||||
yield Ok(Event::default().event("close_stream").data("Stream complete"));
|
||||
break;
|
||||
@@ -257,14 +252,10 @@ pub async fn get_task_updates_stream(
|
||||
)
|
||||
}
|
||||
Ok(None) => Sse::new(create_error_stream(format!(
|
||||
"Task with ID '{}' not found.",
|
||||
task_id
|
||||
"Task with ID '{task_id}' not found."
|
||||
))),
|
||||
Err(e) => {
|
||||
error!(
|
||||
"Failed to fetch task '{}' for authorization: {:?}",
|
||||
task_id, e
|
||||
);
|
||||
error!("Failed to fetch task '{task_id}' for authorization: {e:?}");
|
||||
Sse::new(create_error_stream(
|
||||
"An error occurred while retrieving task details. Please try again later.",
|
||||
))
|
||||
|
||||
@@ -90,10 +90,8 @@ pub async fn create_knowledge_entity(
|
||||
let description = form.description.trim().to_string();
|
||||
let entity_type = KnowledgeEntityType::from(form.entity_type.trim().to_string());
|
||||
|
||||
let embedding_input = format!(
|
||||
"name: {}, description: {}, type: {:?}",
|
||||
name, description, entity_type
|
||||
);
|
||||
let embedding_input =
|
||||
format!("name: {name}, description: {description}, type: {entity_type:?}");
|
||||
let embedding = generate_embedding(&state.openai_client, &embedding_input, &state.db).await?;
|
||||
|
||||
let source_id = format!("manual::{}", Uuid::new_v4());
|
||||
@@ -126,7 +124,7 @@ pub async fn create_knowledge_entity(
|
||||
.collect();
|
||||
let mut unique_ids: HashSet<String> = HashSet::new();
|
||||
|
||||
for target_id in form.relationship_ids.into_iter() {
|
||||
for target_id in form.relationship_ids {
|
||||
if target_id == new_entity.id {
|
||||
continue;
|
||||
}
|
||||
@@ -333,7 +331,7 @@ async fn build_knowledge_base_data(
|
||||
if encoded.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!("&{}", encoded)
|
||||
format!("&{encoded}")
|
||||
}
|
||||
};
|
||||
|
||||
@@ -662,7 +660,7 @@ pub async fn get_knowledge_graph_json(
|
||||
|
||||
let mut degree_count: HashMap<String, usize> = HashMap::new();
|
||||
let mut links: Vec<GraphLink> = Vec::new();
|
||||
for rel in relationships.iter() {
|
||||
for rel in &relationships {
|
||||
if entity_ids.contains(&rel.in_) && entity_ids.contains(&rel.out) {
|
||||
// undirected counting for degree
|
||||
*degree_count.entry(rel.in_.clone()).or_insert(0) += 1;
|
||||
@@ -689,17 +687,14 @@ pub async fn get_knowledge_graph_json(
|
||||
}
|
||||
// Normalize filter parameters: convert empty strings or "none" (case-insensitive) to None
|
||||
fn normalize_filter(input: Option<String>) -> Option<String> {
|
||||
match input {
|
||||
None => None,
|
||||
Some(s) => {
|
||||
let trimmed = s.trim();
|
||||
if trimmed.is_empty() || trimmed.eq_ignore_ascii_case("none") {
|
||||
None
|
||||
} else {
|
||||
Some(trim_matching_quotes(trimmed).to_string())
|
||||
}
|
||||
input.and_then(|s| {
|
||||
let trimmed = s.trim();
|
||||
if trimmed.is_empty() || trimmed.eq_ignore_ascii_case("none") {
|
||||
None
|
||||
} else {
|
||||
Some(trim_matching_quotes(trimmed).to_string())
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn trim_matching_quotes(value: &str) -> &str {
|
||||
@@ -739,8 +734,8 @@ pub async fn show_edit_knowledge_entity_form(
|
||||
"knowledge/edit_knowledge_entity_modal.html",
|
||||
EntityData {
|
||||
entity,
|
||||
user,
|
||||
entity_types,
|
||||
user,
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ pub struct Pagination {
|
||||
}
|
||||
|
||||
impl Pagination {
|
||||
pub fn new(
|
||||
pub const fn new(
|
||||
current_page: usize,
|
||||
per_page: usize,
|
||||
total_items: usize,
|
||||
|
||||
Reference in New Issue
Block a user